1/17
Looks like no tags are added yet.
Stacks
A ___ is a linear data structure in which elements are inserted and removed from the same end, called the top. It follows the Last In, First Out(LIFO) principle.
Queues
A ___ is a linear data structure in which elements are inserted at the rear and removed from the front. It follows the First In, First Out (FIFO) principle.
Stack Operations
push (), pop(), peek () / top (), isEmpty ()
push ()
Add element x to the top of the stack
pop ()
Remove and return the element at the top
peek () / top ()
Return the top element without removing it
isEmpty ()
Check whether the stack has any elements
Queue Operation
enqueue (), dequeue (), front (), isEmpty ()
enqueue ()
Add element x to the rear of the queue
dequeue ()
Remove and return the element at the front
front ()
Return the front element without removing it
isEmpty ()
Check whether the queue has any elements
Circular Queue
A ____ is an array-based queue wheere the front and rear indices wrap around to the beginning once they reach the end, reusing freed slots instead of shifting elements
Deque
A ___ allows insertion and deletion at both ends — front and rear. It generalizes both the stack (use one end only) and queue (use both ends in FIFO order)
insertFront ()
Add x to the front
insertRear ()
Add x to the rear
deleteFront ()
Remove from the front
deleteRear ()
Remove from the rear