1 / 27

Lecture 14: Queues

CompSci 105 SS 2005 Principles of Computer Science. Lecture 14: Queues. Lecturer: Santokh Singh. Test Information on Course Web Page. See the “Test and Exams” Section. Please try not to be late for classes. Tail References. What is the advantage of having a “tail”?. Beer. Milk. Wine.

Download Presentation

Lecture 14: 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. CompSci 105 SS 2005 Principles of Computer Science Lecture 14: Queues Lecturer: Santokh Singh

  2. Test Information on Course Web Page. • See the “Test and Exams” Section. • Please try not to be late for classes.

  3. Tail References What is the advantage of having a “tail”? Beer Milk Wine head tail Textbook, pp. 186

  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 How do you get the first Node here if the external reference “list” shown above references the last Node? – pg 188. Beer Milk Wine list (head) Textbook, pp. 187ff

  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. Dummy Head Nodes What is the advantage of having a Dummy Head? Milk Wine head Textbook, pp. 189ff

  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 0 1 2 3 4 5 6 7 items: 3 5 1 top: 2 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 1 3 5 top Java Code, Textbook, pp. 263ff

  23. ADT List Implementation • 1 • 5 • 3 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

More Related