









































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Major points from this lecture are: Priority Queues and Heaps, Bag Interface, Stacks and Queues as Lists, Priority Queue, Priority Queues as Lists, Important Special Case, Heaps, Balanced Heaps, Vector, Arraylist . Object-Oriented Programming and Data Structures course includes program structure and organization, object oriented programming, graphical user interfaces, algorithm analysis, recursion, data structures (lists, trees, stacks, queues, heaps, search trees, hash tables, graphs), simple g
Typology: Lecture notes
1 / 49
This page cannot be seen from the preview
Don't miss anything!










































interface
Bag
{
void
insert(E
obj);
E^ extract();
//extract
some
element
boolean
isEmpty();
puts new element at front – O(1)
-^ extract()
must search the list – O(n)
must search the list – O(n)
-^ extract()
gets element at front – O(1)
Least element in any subtreeis always found at the rootof that subtree
Note: 19, 20 < 35: we can often findsmaller elements deeper in the tree!
implies that any two maximal paths (path from a rootto a leaf) are of length d or d – 1, and the tree has atleast 2
d^ nodes
-^
0
1
2
3
4
5
6
7
8
9
10
11
children of node n are found at 2n + 1 and 2n + 2
0
1
2
3
4
5
6
7
8
9
10
11
4
6
14
21
8
19
35
22
38
55
10
20
children of node n are found at 2n + 1 and 2n + 2
0 1
2
3
4
5
6
7
8
9
10
11 4
14
6 21
19 8
35
22
55 38
10
20
docsity.com