DS 6
DS 6
front = 0 rear = 3
• To insert: put new element in location 4, and set rear to 4
• To delete: take element from location 0, and set front to 1
Queue
front = 0 rear = 3
Initial queue: 17 23 97 44
front = 1 rear = 4
• Notice how the array contents “crawl” to the right as elements are
inserted and deleted
• This will be a problem after a while!
Main queue operations
• Waiting lines
• Access to shared resources (e.g., printer)
• Scheduling Algorithms
Array based Implementation of Queues
4 8 6
An array of
integers to We don't care what's in
implement a this part of the array.
queue of integers
Array based Implementation of Queues
4 8 6
Array based Implementation of Queues
2 last
4 8 6
Array based Implementation of Queues
3 last
8 6 2
Array based Implementation of Queues
4 8 6
Array based Implementation of Queues
5 last