1 / 16

Abstract Data Types (ADT) Queues

Abstract Data Types (ADT) Queues. Authors: Robin Gajadhar Anthony George Christian Loregnard. Objectives. Queue/ Linear queue Enqueue Dequeue Empty Circular queue Linear queue Priority queue Double ended queue.

jaxon
Download Presentation

Abstract Data Types (ADT) Queues

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Abstract Data Types (ADT) Queues Authors: Robin Gajadhar Anthony George Christian Loregnard

  2. Objectives • Queue/ Linear queue • Enqueue • Dequeue • Empty • Circular queue • Linear queue • Priority queue • Double ended queue

  3. What are queues ( pronounced “Q”)? • A linear list where data can be entered from the end (rear) and deleted at the beginning (front) • Eg. A line of celebrities try to get into a club, they reach the beginning (front) of the line and enter and more celebrities join the line from the back (rear).

  4. Applications related to Computer Science • Threads • Job scheduling (e.g. Round-Robin algorithm for CPU allocation)

  5. Applications of Queues • Direct applications • Waiting lists • Access to shared resources (e.g., printer) • Multiprogramming • Indirect applications • Auxiliary data structure for algorithms • Component of other data structures

  6. Circular Queue • Circular Queue is like a linear queue but in addition, it's last element have a pointer to it's first element. Also called ring buffer.

  7. Priority Queue • Think of a priority queue as a kind of bag that holds priorities. You can put one in, and you can take out the current highest priority.

  8. Priority Queue • A priority queue is different from a "normal" queue, because instead of being a "first-in-first-out" data structure, values come out in order by priority. Each time the printer is free, the job with the highest priority would be removed from the print queue, and printed.

  9. Example • Think of celebrities trying to enter a club, popular celebrities go first, less popular celebrities enter second, bad celebrities enter third and regular people will enter last, they are of lower priority. The popular celebrities would leave the queue first.

  10. Double ended queue • A queue that allows items to be added or removed from either the front or the back of the queue. Often written as Deque and pronounced like "deck" to avoid confusing with DequeueOperation??. A DoubleEndedQueue is usually implemented using DoubleLinkedList.

  11. Example • A line of domino blocks. You can either add or remove a block from the front or back.

  12. Queue operation • Creates an empty queue • Eg. Setting crowd barriers at a bank before the crowd arrives

  13. Enqueue operation • Inserts an item at the rear of the queue (eg.More female celebrities join at the back of the line) • Justin Beiber • Beyonce • NickiMinaj • Kim Kardashian • Eve • Alicia Keys

  14. Dequeue operation • Remove a job at the start(front) of the queue. Justin Beiber is removed from the queue. Justin Beiber Beyonce NickiMinaj Kim Kardashian Eve Alicia Keys

  15. Empty operation • Check to see whether or not the queue is empty. Returns true if it is and false if not.

  16. End of Presentation • An easy way to remember the operations is • Queens Eat Dry Eggs • Queue EnqueueDeque Empty

More Related