This project implements core data structure operations using array-based implementations in C, including:
- Stack Operations
- Circular Queue Operations
Each operation is designed to help understand fundamental data structures through practical, menu-driven C programs.
A stack is a linear data structure that follows the LIFO (Last In, First Out) principle. This project demonstrates:
- Push: Add an element to the top.
- Pop: Remove the top element.
- Display: Show stack contents.
A circular queue uses a fixed-size array and wraps around when reaching the end. It operates on the FIFO (First In, First Out) principle. This project includes:
- Insert: Add an element to the rear.
- Delete: Remove an element from the front.
- Display: Show all elements in queue order.
These are console-based interactive programs ideal for learning and demonstration.
- Push elements to the stack.
- Pop elements from the top.
- Display stack from top to bottom.
- Overflow and underflow handling.
- Insert elements at the rear.
- Delete elements from the front.
- Circular behavior with wrapping.
- Handles overflow and underflow conditions.
- A C compiler (e.g., GCC, Clang)
- Terminal or IDE (e.g., Code::Blocks, VS Code)
-
Clone the repository:
git clone https://github.com/schrodingercats-sudo/data-structure-operations.git cd data-structure-operations -
Compile the code:
-
For stack:
gcc stack_operations.c -o stack
-
For circular queue:
gcc circular_queue.c -o circular_queue
-
-
Run the programs:
-
Stack:
./stack
-
Circular Queue:
./circular_queue
-
Enter the size of STACK[MAX=100]:
5
STACK OPERATIONS USING ARRAY
-------
1.PUSH
2.POP
3.DISPLAY
4.EXIT
Enter the Choice: 1
Enter a value to be pushed: 10
1.Insert
2.Delete
3.Display
4.Quit
Enter your choice: 1
Input the element for insertion in queue: 25
push()– Adds an element to the top of the stack.pop()– Removes the top element from the stack.display()– Shows the stack elements from top to bottom.
insert()– Adds an item to the queue. Handles wrap-around logic.deletion()– Deletes the front item. Updatesfrontandrearcorrectly.display()– Shows the queue in correct order, including wrap-around.