Professional Documents
Culture Documents
Algorithms-II : CS345A
Website: hello.iitk.ac.in
Lecture 4
• Algorithm for Joint Seat Allocation (final discussion)
• Divide and Conquer Paradigm - III
• Convex Hull
1
Homework from the last class
1. Are there multiple fair allocations if there are multiple merit lists ?
Ponder over it …
2
Multiple merit lists
A B C
4
PROBLEM 3
Convex Hull
5
A Convex Polygon
Definition: A polygon is convex if for any two points belonging to the polygon,
the line segment joining them is inside the polygon.
6
Convex hull
Definition: Convex polygon of smallest area enclosing a set of points.
8
Tool 2
𝑦 =𝑚𝑥 +𝑐
𝑟 =( 𝑎 2 , 𝑏2 )
9
DIVIDE AND CONQUER ALGORITHM
Convex Hull
10
The Divide Step
O() time
2 T() time
15
The right half set is a point
16
The right half set is a point
Tool 1
𝑞
Up
p er
tan
ge
nt
𝑝
e nt
g
tan
wer
Lo
𝑟
17
The right half set is a point
Upper Hull
Up
p er
tan
ge
nt
Lemma:
Upper tangent from will be incident on exactly one point of the upper hull.
18
The right half set is a point
𝑝
t
gen
an
rt
owe
L
20
How to compute the upper tangent ?
Tool 2 𝑠
𝑤 𝑞
𝑡 𝑝
𝑟
Worst case time complexity for finding upper tangent: O() time.
We need better time complexity.
21
How to compute the upper tangent ?
𝑠
𝑤 𝑞
𝑡 𝑝
𝑟
22
How to compute the upper tangent ?
𝑠
𝑤 𝑞
𝑡 𝑝
𝑟
23
How to compute the upper tangent ?
𝑠
𝑤 𝑞U O(log ) time
pp
er
tan
ge
nt
𝑡
binary search
𝑝
𝑟
24
Going back to the original problem
Conquer Step
25
The Conquer step
gent
Upper tan
Lower tangen
t
points points 26
How to compute the upper tangent ?
O(log ) time
𝑤 𝑥
𝑣
𝑢
𝑦
points points 27
Running time of the algorithm
What is the recurrence for running time?
c
Theorem:
There exists an O( ) time algorithm to compute the convex hull of points in
plane.
28
Homework
29