the queue n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The Queue PowerPoint Presentation
Download Presentation
The Queue

Loading in 2 Seconds...

play fullscreen
1 / 7

The Queue - PowerPoint PPT Presentation


  • 133 Views
  • Uploaded on

The Queue. Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find out how to do it. Theodore Roosevelt. Queue.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'The Queue' - doctor


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
the queue

The Queue

Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find out how to do it.

Theodore Roosevelt

queue
Queue
  • a list (initially empty) of items (of some type) to which items may be added at one end (called the rear) and from which items may be removed at the other end (called the front)
  • examples
    • waiting lines
    • print queues
    • process queue
  • behaviour
    • FIFO ordering
  • error conditions:
    • underflow
    • overflow
queue interface
Queue Interface
  • generic (Stores objects of type E)
    • no requirements
  • operations:
    • enter (enqueue, add, insert)
    • leave (dequeue, remove, delete)
    • front (head, first)
    • length (count, size)
    • empty
  • exceptions
    • NoItemException
    • NoSpaceException
queue adt contiguous implementation
Queue ADTContiguous Implementation
  • based on variable-sized array
    • two indices: front & rear
    • add at rear, remove at front
    • queue moves towards rear
      • repositioning on delete: O(n)
    • circular array
      • at end of array reuse front
      • index modulo array size
queue adt
Queue ADT.
  • implementation
    • instance variables
      • count
    • constructors
      • empty state
    • methods
      • enter
        • overflow
        • increment
      • leave, front
        • underflow
      • length, empty
        • compute?
        • empty vs full
queue adt linked implementation
Queue ADTLinked Implementation
  • sequentially-linked structure of items
    • deletion from front
    • insertion at end
      • keep pointer to rear O(1)
  • length?
    • keep count else O(n)
  • comparison with contiguous
    • all operations O(1)
    • space tradeoffs