CS 106B Lecture Notes - Lecture 20: Binary Heap, Priority Queue, Linked List

72 views2 pages

Document Summary

Logistics: if you used a for loop like this on the exam and got points off, please submit a regrade: Foreach (int x in collection: regrade requests due friday, current assignment: priority queue, extra late day! How to destroy linked list: big idea. Traverse the list and call delete on each node. Don"t try to use memory you"ve already deleted: clear function that performs destructor. Don"t call constructor, however: when a function comes to its end, the linkedlist will get its destructor called. In order to call clear, we need to save the next pointer of head in a temporary variable, delete it, and then set head to be equal to temp. Priority queue: we want to store data in a prioritized way. Professor office hours (what if a professor walks in?) Getting on an airplane (first class, frequent flyers, then by row, etc. : priority queue explained. Peekpriority: returns priority of the highest priority element.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers