CSN-523: Computational Geometry: Indian Institute of Technology Roorkee
CSN-523: Computational Geometry: Indian Institute of Technology Roorkee
2
Grahams Algorithm:
3
Grahams Algorithm:
4
Grahams Algorithm:
5
Grahams Algorithm:
6
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
7
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
8
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
9
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
10
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
11
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
12
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
13
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
14
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
15
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
16
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
17
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
18
Graham Scan: Example
p10
p9 p6
p12 p7 p5
p4 p3
p11
p8 p1
p2
p0
19
Grahams Algorithm:
Version A
20
Implementation of Grahams Algorithm:
21
Implementation of Grahams Algorithm:
22
Implementation of Grahams Algorithm:
23
Implementation of Grahams Algorithm:
24
Lower Bound: Limitations of Algorithm Power
25
Lower Bound:
Examples:
number of comparisons needed to find the largest element in
a set of n numbers
number of comparisons needed to sort an array of size n
number of comparisons necessary for searching in a sorted
array
number of multiplications needed to multiply two n-by-n
matrices
26
Lower Bound:
27
Methods for Establishing Lower Bounds:
adversary arguments
problem reduction
28
Trivial Lower Bounds:
Examples
finding max element -- n steps or n/2 comparisons
polynomial evaluation
sorting
element uniqueness
Hamiltonian circuit existence
Conclusions
may and may not be useful
30
Decision Trees and Sorting Algorithms:
Any comparison-based sorting algorithm can be represented by a
decision tree (for each fixed n)
Ex. Prove that 5 (or 7) comparisons are necessary and sufficient for sorting
4 keys (or 5 keys, respectively).
31
Adversary Arguments:
Adversary argument: Its a game between the adversary and the (unknown)
algorithm. The adversary has the input and the algorithm asks questions to the
adversary about the input. The adversary tries to make the algorithm work the
hardest by adjusting the input (consistently). It wins the game after the lower
bound time (lower bound proven) if it is able to come up with two different inputs.
34
Lower Bound of CH(P):
35
Optimality of ( log ):
36