CS 2110 Lecture Notes - Lecture 16: Priority Queue, Binary Tree, Southwest Ohio Regional Transit Authority

74 views4 pages
14 Jun 2017
Course
Professor

Document Summary

Lecture 16 - heaps: abstract data structures vs concrete data structures. Adding to anywhere takes time proportional to length of list. Adv. getting something at position i takes constant time. Adding to beginning of list is a constant time. Getting something at position i takes time proportional to i: so arraylist and linkedlist are concrete data structures, some others. Only add at end, remove from beginning: abstract data structures are essentially interfaces. Implements iterable: today we are going to implement a priority queue and heaps. Priority queue - a bag in which data items are comparable. Essentially compare elements in the queue to determine order. Examples: interface priorityqueue { boolean add void clear. Unordered list add() put element at front o(1) poll() must search the list o(n) peek() must search the list o(n) Ordered (prioritized) add() o(n) has to search list to find where to insert it poll() min element at front o(1)

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