This project demonstrates the implementation of Stack and Queue data structures using Linked Lists. It was developed as part of an academic assignment.
-
Push operation: Adds an element to the stack.
-
Pop operation: Removes the top element from the stack.
-
Peek operation: Views the top element without removing it.
-
Check if the stack is empty.
-
Enqueue operation: Adds an element to the rear of the queue.
-
Dequeue operation: Removes the front element from the queue.
-
Peek operation: Views the front element without removing it.
-
Check if the queue is empty.
A Stack follows the LIFO (Last-In, First-Out) principle, meaning elements are added and removed from the top.
-
push(value): Adds an element to the top of the stack. -
pop(): Removes and returns the top element. If the stack is empty, it returns"Stack is empty." -
peek(): Returns the top element without removing it. If the stack is empty, it returns"Stack is empty." -
isEmpty(): Checks whether the stack is empty. -
stackSize(): Returns the current size of the stack. -
displayStack(): Displays all elements in the stack, from top to bottom.
A Queue follows the FIFO (First-In, First-Out) principle, where elements are added at the rear and removed from the front.
-
enqueue(element): Adds an element to the rear of the queue. -
dequeue(): Removes and returns the element from the front. If the queue is empty, it returns"Queue is empty." -
peek(): Returns the front element without removing it. If the queue is empty, it returns"Queue is empty." -
isEmpty(): Checks whether the queue is empty. -
size(): Returns the current size of the queue. -
displayQueue(): Displays all elements in the queue, from front to rear.
-
Push: ( O(1) )
-
Pop: ( O(1) )
-
Peek: ( O(1) )
-
Enqueue: ( O(1) )
-
Dequeue: ( O(1) )
-
Peek: ( O(1) )
-
Name: Muhammad Bilal
-
Father's Name: Muhammad Sher
-
Degree Program: BSCS Evening
-
Section: A
-
LinkedIn: Muhammad Bilal's LinkedIn Profile# DSA-assinment-