You are on page 1of 4

Exercise set 9

CSC2100 Data Structure

CUHK

April 6, 2010
Show the AVL-tree after inserting key 36.
40

15 73

10 30 60 80

3 20 35
Show the AVL-tree after deleting key 35.
30

15 40

10 20 35

3 25
Let S be a set of n horizontal segments, and P be a set of m
points, all in a 2d space. Give an algorithm to find, for each point
p ∈ P, the segment in S above it. Your algorithm should
terminate in O(n log n + m log m) time.
Example
s1

p1 s2

p3 s4 p4
p2
s3

S = {s1 , ..., s4 }, P = {p1 , ..., p4 }.


Result = {(p1 , s1 ), (p2 , s2 ), (p3 , s2 ), (p4 , ∅)}.

You might also like