Professional Documents
Culture Documents
1
9/17/2015
E =E = ]
1 1)
= =
2
2
9/17/2015
3
9/17/2015
4
9/17/2015
E =
+1
MAT-72006 AADS, Fall 2015 17-Sep-15 189
E =E = ]
=
+1
1
(ln (1))
• By harmonic series
MAT-72006 AADS, Fall 2015 17-Sep-15 190
5
9/17/2015
II (Sorting and)
Order Statistics
Heapsort
Quicksort
Sorting in Linear Time
Medians and Order Statistics
6
9/17/2015
7
9/17/2015
8
9/17/2015
MINIMUM )
1. min [1]
2. for 2 to
3. if min > ]
4. min ]
5. return min
9
9/17/2015
10
9/17/2015
11
9/17/2015
12
9/17/2015
RANDOMIZED-PARTITION )
1. RANDOM )
2. exchange ] with ]
3. return PARTITION )
13
9/17/2015
14
9/17/2015
RANDOMIZED-SELECT )
1. if
2. return ]
3. RANDOMIZED-PARTITION )
4. +1
5. if // the pivot value is the answer
6. return ]
7. elseif
8. return RANDOMIZED-SELECT 1, )
9. else return RANDOMIZED-SELECT( , + 1, , )
MAT-72006 AADS, Fall 2015 17-Sep-15 210
15
9/17/2015
16
9/17/2015
17
9/17/2015
18
9/17/2015
(max( 1, )) + ))
= (max( 1, )) + )
E E (max( 1, )) + )
= E[ (max( 1, ))] + )
= E E[ (max( 1, ))] + )
1
= E[ (max( 1, ))] + )
19
9/17/2015
20
9/17/2015
Dynamic sets
21
9/17/2015
MAXIMUM )
• Return a pointer to the • We usually measure
element of with the largest the time taken to
key
SUCCESSOR )
execute a set
• Given an element whose operation in terms of
key is from a totally ordered the size of the set
set , return a pointer to the
next larger element in , or • E.g., we later describe
NIL if is the max element a data structure that
PREDECESSOR ) can support any of the
• Given an element whose
key is from a totally ordered
operations on a set of
set , return a pointer to the size in time (lg )
next smaller element in , or
NIL if is the min element
11 Hash Tables
22
9/17/2015
23
9/17/2015
24
9/17/2015
CHAINED-HASH-INSERT )
1. insert at the head of list ]
CHAINED-HASH-SEARCH )
1. search for element with key in list ]
CHAINED-HASH-DELETE )
1. delete from the list [ . ]
MAT-72006 AADS, Fall 2015 17-Sep-15 230
25
9/17/2015
26
9/17/2015
27
9/17/2015
28
9/17/2015
1
= 1+ E
1 1
= 1+
1
=1+ )
1
=1+
1 + 1)
=1+
2
1
=1+ +=1+
2
Thus, the total time required for a successful
search is 2 + 2 + 1+
29
9/17/2015
30