KEMBAR78
Stack queue | PDF
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
mazhar940@gmail.com and muktijadhav@gmail.com
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-loaded
plate 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 of
the 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 First
Out)
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 elements
may 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 free
space you get overflow.
If you try to remove an element from an empty queue or stack you
get 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

Stack queue

  • 1.
    Operations on Stackand Queue Dr M M Kazi and Dr Mukti Jadhav Dr. G. Y. Pathrikar College of CS and IT and MIT College Aurangabad mazhar940@gmail.com and muktijadhav@gmail.com July 4, 2016 Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 1 / 13
  • 2.
    Overview 1 Data Structure 2Stack 3 Queue 4 Comparison Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 2 / 13
  • 3.
    Data Structure You havealready 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
  • 4.
    Data Structure Other datastructures 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
  • 5.
    Stack Example The terminology associatedwith stacks comes from the spring-loaded plate 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
  • 6.
    Stack Working New elements areadded to the top of the stack. The item at the top of the 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
  • 7.
    Queue Example Queues are datastructures that maintain the order of FIFO (First In First Out) Figure Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 7 / 13
  • 8.
    Queue Example New elements mayonly be added to the end of a queue; and elements may 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
  • 9.
    Comparison: Stack andQueue 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
  • 10.
    Comparison: Stack andQueue 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 free space you get overflow. If you try to remove an element from an empty queue or stack you get underflow. Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 10 / 13
  • 11.
    Citation The examples andother 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
  • 12.
    References Contributory work (2016) http://aqaa2computing.wikispaces.com/ Visitedon 4 July 2016. Dr M M Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 12 / 13
  • 13.
    The End Dr MM Kazi and Dr Mukti Jadhav (DR GYP) Stack and Queue July 4, 2016 13 / 13