1
COMP 250
Lecture 8
queue ADT
- Sept. 23, 2016
queue ADT Sept. 23, 2016 1 Queue dequeue (remove from enqueue - - PowerPoint PPT Presentation
COMP 250 Lecture 8 queue ADT Sept. 23, 2016 1 Queue dequeue (remove from enqueue front) (add at back) Queues are heavily used in OS (operating systems) e.g. process scheduling. 2 Queue Stack enqueue( e ) push(e) dequeue() pop()
1
2
Queues are heavily used in OS (operating systems) e.g. process scheduling.
3
Although stacks and queues consist of a finite ordered set of elements, strictly speaking, they are not lists since their operations do not allow one to index directly to the arbitrary elements.
4
5
6
7
removeFirst (& shift) removeFirst (& shift) removeFirst (& shift)
indices
8
Start with length = 4. Need to increase length of array.
10
b c c d e
11
12
13
14
15
tail head head tail
head = 1 tail = 0 size = 4 head = 0 tail = 3 size = 4
16
17
18
top
top
19