Professional Documents
Culture Documents
P13 Stack Queue
P13 Stack Queue
Representation of data and the operations allowed on that data. For organizing and storing data in an ordered and controlled way. Two types Linear Non-linear
DATA STRUCTURE
Linear Array Linked list Stack Queue Non-linear Tree Graphs
STACK
Stack is an ordered collection of items into which new items may be inserted and from which items may be deleted at one end, called the top of the stack.
E D C B A
STACK
Unlike array, definition of stack provides insertion and deletion of items Single end of the stack is designed as the stack top New items are placed on top of stack
STACK
LIFO
STACK
Insert an item into stack Fullstack() Check whether the stack is full or not
Pop
Remove an item from the stack Emptystack() Check whether the stack is empty or not
STACK-PUSH
the stack is full, print a warning message and halt execution Insert an element on top of stack
STACK-POP
the stack is empty, print a warning message and halt execution Remove the top element from the stack Return this element to the calling program
STACK
Stack-allocated memory
When
a function is called, memory is allocated for all of its parameters and local variables. Each active function call has memory on the stack (with the current function call on top)
11
STACK
When
Ex:main()
QUEUE
Queue is an ordered collection of items from which items may be deleted at one end and into which items may be inserted at the other end FRONT Front-For deletion A B C Rear-For insertion
REAR
QUEUE
FRONT A B C REAR FRONT FIFO B C REAR FRONT B C D E REAR
QUEUE-INSERT
Inserted at the rear end PERFORMS THE FOLLOWING ACTIONS
Check
QUEUE-DELETE
Elements removed from the front end of the queue. PERFORMS THE FOLLOWING ACTIONS
Check
or not Remove the front element from the queue Return this element to the calling program
QUEUE
QUEUE-INSERT
If Rear>5 Queue overflow Else Insert element into queue
FRONT B C D E REAR
QUEUE-DELETE
If front=rear Queue underflow Else Return queue[front] element
FRONT B C D E REAR
QUEUE
Task scheduler I/O Buffering
I request Electronics and communication ENGINEERING students to visit my blog for more abhishek1ek.blogspot.com awhengineering.blogspot.com