









































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
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