Dictionaries: Collection of Items. Each Item Is A Pair
Dictionaries: Collection of Items. Each Item Is A Pair
Application
Collection of student records in this class.
(key, element) = (student name, linear list of assignment and exam scores) All keys are distinct. Collection of in-use domain names.
(godaddy.com, owner information) All keys are distinct.
Dictionary Operations
Static Dictionary.
initialize/create get(theKey) (a.k.a. search) CD ROM word dictionary CD ROM geographic database of cities, rivers, roads, auto navigation system, etc.
Dynamic Dictionary.
get(theKey) (a.k.a. search) put(theKey, theElement) (a.k.a. insert) remove(theKey) (a.k.a. delete)
Bin Packing
n items to be packed into bins each item has a size each bin has a capacity of c minimize number of bins
Best Fit
n=4 weights = [4, 7, 3, 6] capacity = 10
Best Fit
n=4 weights = [4, 7, 3, 6] capacity = 10
Best Fit
n=4 weights = [4, 7, 3, 6] capacity = 10
Best Fit
n=4 weights = [4, 7, 3, 6] capacity = 10
Best Fit
n=4 weights = [4, 7, 3, 6] capacity = 10
Optimal packing.
10 6 15 30
40
2 7
18
25
35
4
10
3
40
1
6
0
15
1 0
18
30
0
2 8
0
25
0
35
4
10
3
40
1
6
0
15
1 0
18
30
0
2 8
0
25
0
35
4
10
3
40
1
6
0
15
1 0
18
30
0
2 8
0
25
0
35
4
e l
3
0 1 0
g
1
b f
0
a d
0
i k
list = [a,b,c,d,e,f,g,h,i,j,k,l]
Performance
Linear List.
get(index) put(index, element) remove(index)
Array.
O(1), O(n), O(n).
Chain.
O(n), O(n), O(n).
Experimental Results
Performance
Indexed AVL Tree (IAVL) Operation FastArrayLinearList get 5.6ms average puts 5.8sec worst-case puts 11.8sec average removes 5.8sec worst-case removes 11.7sec Chain 157sec 115sec 157sec 149sec 157sec IAVL 63ms 392ms 544ms 1.5sec 1.6sec
Focus
Tree structures for static and dynamic dictionaries.