1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science
2 Test Information on Course Web Page. See the “Test and Exams” Section. Please try not to be late for classes.
3 Tail References Beer Wine Milk head Textbook, pp. 186 tail What is the advantage of having a “tail”?
4 Linked Lists Inserting and Deleting Elements Implementing the ADT List Compared to Arrays Passing Linked Lists as Parameters Variations of the Linked List Tail References Circular Linked Lists Dummy Head Nodes
5 Circular Linked Lists Beer Wine Milk list (head) Textbook, pp. 187ff How do you get the first Node here if the external reference “list” shown above references the last Node? – pg 188.
6 Linked Lists Inserting and Deleting Elements Implementing the ADT List Compared to Arrays Passing Linked Lists as Parameters Variations of the Linked List Tail References Circular Linked Lists Dummy Head Nodes
7 Textbook, pp. 189ff Wine Milk head What is the advantage of having a Dummy Head?
8 List ADT Linked List Array
9 List ADT Linked List Array SortedList ADT Linked List Array
10 List ADT Linked List Array SortedList ADT Linked List Array Stack ADT Linked List Array List ADT
11 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT
12 Undo Operations
13 Undo Operations
14 Stack ADT
15 Stack ADT Push Pop
16 Stack ADT void createStack ( ) void isEmpty ( ) void push ( Object newItem ) Object pop () void popAll () Object peek () Textbook, p. 252
17 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT
18 Balancing Parenthesis ( a { b ( ) } ) { a [ b ( c ) d ( ) ) ] } Textbook, pp. 254ff
19 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT
20 Array Implementation items: top: Java Code, Textbook, pp. 260ff
21 Stacks Basic ADT Operations Application: Undo Operations Application: Balancing Parenthesis Array Implementation Linked List Implementation Stack ADT implemented with List ADT
22 Linked List Implementation top Java Code, Textbook, pp. 263ff
23 ADT List Implementation Java Code, Textbook, pp. 263ff
24 Queues Basic ADT Queue Operations "Circular" Array Implementation Linked List Implementation "Circular" Linked List Implementation Queue ADT implement with List ADT
25 Queue
26 Queue
27 Queue ADT void createQueue ( ) void isEmpty ( ) void enqueue ( Object newItem ) Object dequeue () void dequeueAll () Object peek () Textbook, p. 299