COMPSCI 61B Lecture Notes - Lecture 20: Comparator, Binary Tree, Priority Queue

33 views6 pages
12 Mar 2019
School
Professor

Document Summary

Can only interact with the smallest item - care more about quickly finding the smallest or largest element instead of quickly searching. Useful if you want to keep track of the smallest, largest, best, etc. Adt that optimizes for handling minimum or maximum elements. Monitor the text messages of the citizens to make sure that they are not having any unharmonious conversations. Each day, you prepare a report of the m messages that seem most unharmonious using the harmoniousnesscomparator. Create a list of all messages sent for the entire day and sort it using your comparator. Potentially uses a huge amount of memory (n) where n is number of texts. Goal: do this in (m) memory using a minpq. Can track m transactions using only m memory. Api for minpq also makes code very simple. Bsts would work, but need to be kept bushy and duplicates are awkward. Binary min-heap: binary tree that is complete and obeys min-heap property.

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

Related Documents