Sie sind auf Seite 1von 8

Homework 5

B Trees and Hashing

1.

Insert 44

Insert 30

Insert 3

Insert 80

Insert 66 full block, promote middle value 44


Insert 51

Insert 5

Insert 67
Insert 95 block full, promote middle value 67

Insert 14

Insert 22 block full, promote middle value 14


Insert 82

Insert 2

Insert 40
Insert 98
2.

Original B Tree

Delete 74 introduces gap, fill with next largest available value 78

Promote lowest value, 80, from next block to replace demoted value, 78
3.

1 GB = 2^20 KB

1 MB = 2^10 KB

1 GB = 2^20 KB = 4KB (M) + 4KB (M-1)

(2^20 + 4) KB = 8KB (M)

131072.5 = M

131072 = M

1 GB = 2^10 MB = 1 MB (L)

L = 1024

hM = logN(M) = log(N)/log(M) = log(13371337)/log(131072) = 1.39 = 2

hM/2 = logN(M/2) = log(N)/log(M/2) = log(13371337)/log(131072/2) = 1.48 = 2

Best and worst case h = 2

nM = Mh 1 = 1310722 1 = 17,179,869,183 best case

nM/2 = (M/2)h 1 = (131072/2)2 1 = 4,294,967,295 worst case

There are no disk accesses, the first two levels are saved in memory.
4.

Linear: 62 probes

0 28 8 95 16 90 24 24
1 87 9 38 17 46 25 21
2 89 10 39 18 75 26 26
3 31 11 98 19 18 27 27
4 91 12 12 20 49 28 55
5 62 13 41 21 20
6 64 14 11 22 51
7 36 15 43 23 22

Quadratic: 45 probes before 55 could not find a matching place within reasonable time

0 8 95 16 24 24
1 21 9 38 17 46 25 18
2 89 10 39 18 75 26 26
3 31 11 98 19 90 27 27
4 91 12 12 20 49 28
5 62 13 41 21 20
6 64 14 43 22 51
7 36 15 11 23 22

Das könnte Ihnen auch gefallen