Queue and stacks
Upcoming SlideShare
Loading in...5
×
 

Queue and stacks

on

  • 790 views

 

Statistics

Views

Total Views
790
Slideshare-icon Views on SlideShare
755
Embed Views
35

Actions

Likes
0
Downloads
7
Comments
0

4 Embeds 35

http://education.weebly.com 18
http://www.bradfieldweb.com 13
http://www.computinglesson.com 3
http://bradfieldict.weebly.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Queue and stacks Queue and stacks Presentation Transcript

    • Queue and stacks • What they are • How they work • How to make them • Typical problems
    • Sample exam question • What is a queue? • What is a stack? • How can one reverse the other?
    • Queue • First in • First Out FIFO
    • Stack • Last in • First out LIFO
    • The problem with queues • Queues work as you would expect – First in, First out - FIFO – Later items take their turn behind earlier ones. • Because of the ‘no shuffling’ rule, these turn out to be tricky to implement
    • Classic Array-Style Queue • Items are read off the front of the queue W H E R E sp T H E sp Front of Queue Rear of Queue Limit
    • Classic Array-Style Queue • And added to the rear W H E R E sp T H E sp S Front of Queue Rear of Queue Limit Item = W
    • Classic Array-Style Queue • Until we run out of space • Then we’re stuffed. W H E R E sp T H E sp S T R E Front of Queue Rear of Queue Limit Item = WHER Warning: Queue Full!
    • Brilliant Idea! • If you get to the end .. • Wrap round to the front • Until you hit the Rear pointer E E T R E sp T H E sp S T R E Front of QueueRear of Queue Limit Item = WHERE
    • Circular queue • It’s not really a circle! E E T R E sp T H E sp S T R E Front of Queue Rear of Queue EndStart