RED-BLACK TREE SEARCH - PowerPoint PPT Presentation

About This Presentation
Title:

RED-BLACK TREE SEARCH

Description:

THE AVERAGE SIZE OF EACH LIST IS. n / m. FOR THE find METHOD, averageTimeS(n, m) n / 2m iterations. = 0.75 / 2 ... SO AFTER THE INSERTIONS: THIS SOLUTION LEADS ... – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 123
Provided by: WILLIAM944
Category:
Tags: black | red | search | tree | find | the

less

Transcript and Presenter's Notes

Title: RED-BLACK TREE SEARCH


1
(No Transcript)
2
(No Transcript)
3
(No Transcript)
4
(No Transcript)
5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
RED-BLACK TREE SEARCH THE FOLLOWING METHOD IS IN
tree.h OF THE HEWLETT-PACKARD IMPLEMENTATION
11
(No Transcript)
12
(No Transcript)
13
(No Transcript)
14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
(No Transcript)
34
(No Transcript)
35
(No Transcript)
36
(No Transcript)
37
(No Transcript)
38
(No Transcript)
39
(No Transcript)
40
(No Transcript)
41
(No Transcript)
42
(No Transcript)
43
(No Transcript)
44
(No Transcript)
45
(No Transcript)
46
(No Transcript)
47
(No Transcript)
48
(No Transcript)
49
(No Transcript)
50
(No Transcript)
51
(No Transcript)
52
(No Transcript)
53
(No Transcript)
54
(No Transcript)
55
(No Transcript)
56
(No Transcript)
57
(No Transcript)
58
(No Transcript)
59
IMPLEMENTATION OF THE hash_map CLASS
60
(No Transcript)
61
(No Transcript)
62
(No Transcript)
63
(No Transcript)
64
(No Transcript)
65
(No Transcript)
66
(No Transcript)
67
(No Transcript)
68
(No Transcript)
69
(No Transcript)
70
(No Transcript)
71
(No Transcript)
72
(No Transcript)
73
(No Transcript)
74
(No Transcript)
75
(No Transcript)
76
(No Transcript)
77
(No Transcript)
78
(No Transcript)
79
(No Transcript)
80
(No Transcript)
81
(No Transcript)
82
(No Transcript)
83
(No Transcript)
84
(No Transcript)
85
TIME ESTIMATES LET n count, LET m
length. MAKE THE UNIFORM HASHING ASSUMPTION AND
ASSUME THAT count lt length 0.75.
86
THE AVERAGE SIZE OF EACH LIST IS n / m
87
FOR THE find METHOD, averageTimeS(n, m) ? n /
2m iterations.
lt 0.75 / 2 SO averageTimeS(n, m) lt A
CONSTANT. averageTimeS(n, m) IS CONSTANT.
88
(No Transcript)
89
(No Transcript)
90
(No Transcript)
91
(No Transcript)
92
(No Transcript)
93
(No Transcript)
94
(No Transcript)
95
(No Transcript)
96
(No Transcript)
97
(No Transcript)
98
(No Transcript)
99
SOLUTION bool marked_for_removal THE
CONSTRUCTOR SETS EACH buckets
marked_for_removal FIELD TO false. insert SETS
marked_for_removal TO false erase SETS
marked_for_removal TO true. SO AFTER THE
INSERTIONS
100
(No Transcript)
101
(No Transcript)
102
(No Transcript)
103
THIS SOLUTION LEADS TO ANOTHER PROBLEM SUPPOSE
length 203. insert erase // what was just
inserted (insert AND erase A TOTAL OF
202 TIMES) insert count 1, SO THERE IS NO NEED
TO EXPAND AND REHASH. BUT THERE ARE 202
MARKED-FOR-REMOVALS!
104
(No Transcript)
105
max 202, min 0, average
101
106
SOLUTION KEEP TRACK OF REMOVALS int count_plus
// count number of removals since last
rehashing void check_for_expansion()
if (count_plus gt int (MAX_RATIO
length)) // Do
not copy the marked_for_removals.
delete temp_buckets
count_plus count // doubling
buckets size // method check_for_expansion
107
(No Transcript)
108
CLUSTER A SEQUENCE OF NON-EMPTY LOCATIONS
109
(No Transcript)
110
(No Transcript)
111
(No Transcript)
112
SOLUTION DOUBLE HASHING, THAT IS, OBTAIN BOTH
INDICES AND OFFSETS BY HASHING   unsigned
long hash_int hash (key) int index hash_int
length, offset hash_int / length NOW THE
OFFSET DEPENDS ON THE KEY, SO DIFFERENT KEYS
WILL USU- ALLY HAVE DIFFERENT OFFSETS, SO NO
MORE PRIMARY CLUSTERING!
113
TO GET A NEW INDEX index (index offset)
length
114
EXAMPLE length 11 key index
offset 15 4 1 19 8 1 16 5 1 58
3 5 27 5 2 35 2 3 30 8 2 47 3 4 WHERE
WOULD THESE KEYS GO IN buckets?
115
index key 0 47 1 2 35 3 58
4 15 5 16 6 7 27 8 19 9 10 30
116
PROBLEM WHAT IF OFFSET IS MULTIPLE OF
length? EXAMPLE length 11 key
index offset 15
4 1 19 8 1 16 5 1 58 3 5 27 5 2 35 2 3
47 3 4 246 4 22 // BUT 15 IS AT INDEX
4 FOR KEY 246, NEW INDEX (4 22) 11 4.
OOPS!
117
SOLUTION if (offset length 0)
offset 1 ON AVERAGE, offset length
WILL EQUAL 0 ONLY ONCE IN EVERY length TIMES.
118
FINAL PROBLEM WHAT IF length HAS SEVERAL
FACTORS? EXAMPLE length 20 key
index offset 20 0
1 25 5 1 30 10 1 35
15 1 110 10 5 // BUT 30 IS AT
INDEX 10 FOR KEY 110, NEW INDEX (10 5) 20
15, WHICH IS OCCUPIED, SO NEW INDEX (15 5)
20, WHICH IS OCCUPIED, SO NEW INDEX ...
119
SOLUTION MAKE length A PRIME.
120
(No Transcript)
121
(No Transcript)
122
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com