Python Data Struct
Python Data Struct
Memory Allocation
POP Operation
Removing existing elements from the stack list is called pop operation.
Here we have to check if the stack is empty by checking the value of top. If the
value of top is -1, then the stack is empty and such a situation is called Underflow.
Otherwise Pop operation can be performed in the stack. The top is decremented
by one if an element is deleted from the list.
Traversal Operation
Traversal is moving through the elements of the stack. If we want to display all the
elements of the stack.
We already have append and pop functions of list to perform push and pop
operation.
DATA STRUCTURES(Stack)
DATA STRUCTURES(Stack)
DATA STRUCTURES(Stack)
DATA STRUCTURES(Stack)
Queue Operations
Various operations, which can be performed on a queue
are:
• Create a queue having a data structure to store linear
list with ordering of elements.
• Insert an element will happen using REAR, REAR will be
incremented to hold the new value in queue.
• Delete an element will happen using FRONT and
FRONT will also be incremented to be able to access
next element
• Traversal of queue will be from front to rear.
DATA STRUCTURES(Queue)
DATA STRUCTURES(Queue)
DATA STRUCTURES(Queue)