stack queue
TRANSCRIPT
Operations on Stack and Queue
Dr M M Kazi and Dr Mukti Jadhav
Dr. G. Y. Pathrikar College of CS and IT and MIT College Aurangabad
[email protected] and [email protected]
July 4, 2016
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 1 / 13
Overview
1 Data Structure
2 Stack
3 Queue
4 Comparison
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 2 / 13
Data Structure
You have already come across elementary data types.
Integer
Real
Boolean
And some structured data types (data structures).
String
Array
Record
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 3 / 13
Data Structure
Other data structures such as:
Stacks
Queue and
Binary Trees
Have to be constructed by the programmer.
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 4 / 13
Stack
Example
The terminology associated with stacks comes from the spring-loadedplate containers you get in canteens.
Figure
In short
They maintain the order LIFO (Last In First Out)
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 5 / 13
Stack
Working
New elements are added to the top of the stack. The item at the top ofthe stack is the first to be removed.
Figure
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 6 / 13
Queue
Example
Queues are data structures that maintain the order of FIFO (First In FirstOut)
Figure
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 7 / 13
Queue
Example
New elements may only be added to the end of a queue; and elementsmay only be retrieved from the front of a queue.
Pointers mark the front and rear of the queue.
Figure
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 8 / 13
Comparison: Stack and Queue
Stacks used for
Calculations
Used to store the return address when a subroutine is called
Queue used for
Characters typed at a keyboard are held in a keyboard buffer
Output waiting to be printed is commonly stored in a queue
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 9 / 13
Comparison: Stack and Queue
Queues are more difficult to implement than Stacks.
A Stack can be used to reverse a Queue.
Stacks and Queues have preset sizes.
If you try to add an element to a queue or stack that has no freespace you get overflow.
If you try to remove an element from an empty queue or stack youget underflow.
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 10 / 13
Citation
The examples and other material are are cited within the presentation:
The course material in this course requires citation [Wikispaces, 2016].
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 11 / 13
References
Contributory work (2016)
http://aqaa2computing.wikispaces.com/
Visited on 4 July 2016.
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 12 / 13
The End
Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 13 / 13