https://github.com/salma-mamdoh/data-structures-implementation
Our project for Data Structures Course taken during fall 2023 semester
https://github.com/salma-mamdoh/data-structures-implementation
circular-linked-list cpp data-structures doubly-linked-list problem-solving queue single-linked-list stack
Last synced: 4 months ago
JSON representation
Our project for Data Structures Course taken during fall 2023 semester
- Host: GitHub
- URL: https://github.com/salma-mamdoh/data-structures-implementation
- Owner: Salma-Mamdoh
- Created: 2023-04-22T21:20:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T20:42:42.000Z (over 1 year ago)
- Last Synced: 2025-03-30T23:24:46.055Z (8 months ago)
- Topics: circular-linked-list, cpp, data-structures, doubly-linked-list, problem-solving, queue, single-linked-list, stack
- Language: C++
- Homepage:
- Size: 63.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Data Structures Implementation
This project contains implementations of various data structures in C++, including:
- Array-Based List
- Single Linked List
- Doubly Linked List
- Circular Linked List
- Stack
- Queue
Each data structure has its own set of methods that can be used to interact with the structure. Additionally, there are several problems included that can be solved using these data structures.
Array-Based List
The Array-Based List implementation includes the following methods:
insert(elementType element): voidinsertAt(elementType element, int index): voidretrieveAt(int index): elementTyperemoveAt(int index): voidreplaceAt(elementType newElement, int index)isItemAtEqual(elementType element, int index): boolisEmpty(): boolisFull(): boollistSize(): intmaxListSize(): intclear(): voidprint(): void
Single Linked List
The Single Linked List implementation includes the following methods:
insertAtHead(elementType element): voidinsertAtTail(elementType element): voidinsertAt(elementType element, int index): voidremoveAtHead(): voidremoveAtTail(): voidremoveAt(int index): voidretrieveAt(int index): elementTypereplaceAt(elementType newElement, int index)isExist(elementType element): boolisItemAtEqual(elementType element, int index): bool-
swap(int firstItemIdx, int secondItemIdx): void(swap two nodes without swapping data) isEmpty(): boollinkedListSize(): intclear(): voidprint(): void
Doubly Linked List
The Doubly Linked List implementation includes the following methods:
insertAtHead(elementType element): voidinsertAtTail(elementType element): voidinsertAt(elementType element, int index): voidinsertAfter(* prev_node, int data): voidremoveAtHead(): voidremoveAtTail(): voidremoveAt(int index): voidretrieveAt(int index): elementTypereplaceAt(elementType newElement, int index)isExist(elementType element): boolisItemAtEqual(elementType element, int index): bool-
swap(int firstItemIdx, int secondItemIdx): void(swap two nodes without swapping data) -
reverse(): void(reverse the data in the double linked list) isEmpty(): booldoubleLinkedListSize(): intclear(): void-
forwardTraversal(): void(Print from head to tail) -
backwardTraversal(): void(Print from tail to head)
Circular Linked List
The Circular Linked List implementation includes the following methods:
insertAtHead(elementType element): voidinsertAtEnd(elementType element): voidinsertAt(elementType element, int index): voidremoveAtHead(): voidremoveAtEnd(): voidremoveAt(int index): voidretrieveAt(int index): elementTypereplaceAt(elementType newElement, int index)isExist(elementType element): boolisItemAtEqual(elementType element, int index): bool-
swap(int firstItemIdx, int secondItemIdx): void(swap two nodes without swapping data) isEmpty(): boolcircularLinkedListSize(): intclear(): voidprint(): void
Stack
The Stack implementation includes the following methods:
push(elementType element): voidpop(): voidtop(): elementTypeisEmpty(): boolisFull(): boolstackSize(): int
Queue
The Queue implementation includes the following methods:
enqueue(elementType element): voiddequeue(): voidfront(): elementTypeisEmpty(): boolisFull(): boolqueueSize(): int
Problems
This project includes several problems that can be solved using the implemented data structures. These problems are:
Linked List Problems
Problem 1: Combine Nodes Between Zeros
Given a linked list containing a sequence of integers separated by 0s, merge all nodes between any two consecutive 0s into a single node whose value is the total of all the merged nodes. There are no two consecutive nodes with value == 0. There should be no 0s in the new list.
Problem 2: Merge K Sorted Linked Lists
Given k linked-lists, each linked-list is sorted in ascending order, merge all the linked-lists into one sorted linked-list.
Stack Problems
Problem 1: Convert the Infix Expression to Postfix Expression
Given a string representing an infix expression, convert it to postfix expression.
Problem 2: Longest Valid Parentheses
Given a string containing the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.
Queue Problems
Problem 1: Generate Binary Numbers from 1 to N
Write a function that generates and prints all binary integers from 1 to N.
Problem 2: Implement a Stack
Implement a stack that supports push and pop operations using the enqueue and dequeue operations of the queue. You can use one or more queues.
Problem 3: Sorting a Queue
Given a queue with random integer elements, sort it.