Presentation is loading. Please wait.

Presentation is loading. Please wait.

Segment Tree and Its Usage for geometric Computations

Similar presentations


Presentation on theme: "Segment Tree and Its Usage for geometric Computations"— Presentation transcript:

1 Segment Tree and Its Usage for geometric Computations
Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty April 2012 Segment Tree

2 Motivation We may be interested in calculating the underling area, perimeter or contour construction April 2012 Segment Tree

3 Segment Tree Definition
Introduced by J. L. Bentley in 1977 Data structure designed to handle intervals on the real line Intervals end points belong to a fixed set of abscissas Abscissas can be normalized to range [1,N] without loss of generality by using a lookup table Given an interval [l,r], the segment tree T(l,r) is a rooted binary tree defined recursively April 2012 Segment Tree

4 April 2012 Segment Tree

5 April 2012 Segment Tree

6 4,15 9,15 4,9 6,9 4,6 12,15 9,12 5,6 4,5 7,9 6,7 10,12 9,10 13,15 12,13 8,9 7,8 11,12 10,11 14,15 13,14 April 2012 Segment Tree

7 Insertion and Deletion
April 2012 Segment Tree

8 Insertion and Deletion
April 2012 Segment Tree

9 April 2012 Segment Tree

10 1,257 1,129 65,129 97,129 65,97 65,81 81,97 97,115 105,109 97,105 105,115 105,107 73,81 73,77 73,75 74,75 75,77 77,81 April 2012 Segment Tree

11 April 2012 Segment Tree

12 April 2012 Segment Tree

13 Allocation and De-Allocation
Depends on application. If we wish to know the cardinality of cover of [B[v],E[v]] then a counter C[v] is associated with node v: C[v] = C[V]+1 is allocation for INSERT C[v] = C[V]-1 is de-allocation for DELETE In many cases C[v] indicates the presence of material, so we’ll be interested in whether C[v] > 0 (material exists) or C[v]==0 (no material). April 2012 Segment Tree

14 1D Measure of Union of Intervals
April 2012 Segment Tree

15 1D Measure of Union of Intervals
April 2012 Segment Tree

16 April 2012 Segment Tree

17 2D Measure (Area) of Union of Rectangles
April 2012 Segment Tree

18 2D Measure (Area) of Union of Rectangles
April 2012 Segment Tree

19 scan-line April 2012 Segment Tree

20 Efficient Calculation of m(xi)
April 2012 Segment Tree

21 April 2012 Segment Tree

22 April 2012 Segment Tree

23 Perimeter of Union of Rectangles
Perimeter is the length sum of: vertical edges horizontal edges April 2012 Segment Tree

24 April 2012 Segment Tree

25 April 2012 Segment Tree

26 April 2012 Segment Tree

27 April 2012 Segment Tree

28 April 2012 Segment Tree

29 April 2012 Segment Tree

30 The Contour of Union of Rectangles
April 2012 Segment Tree

31 April 2012 Segment Tree

32 April 2012 Segment Tree

33 April 2012 Segment Tree

34 April 2012 Segment Tree

35 April 2012 Segment Tree

36 April 2012 Segment Tree

37 April 2012 Segment Tree

38 April 2012 Segment Tree

39 April 2012 Segment Tree

40 Completing the Cycles of Contour
April 2012 Segment Tree

41 April 2012 Segment Tree

42 e1 e3 e2 e6 e5 e8 e7 e4 e9 e10 April 2012 Segment Tree

43 There’s no ambiguity in deciding whether to go to left or right triplet when an horizontal edge is decided. It follows that a pair of successive triplets defines horizontal edges. Consequently, once two successive triplets are traversed and define a new horizontal edge, the number of triplets on both the left and the right parts of the list must be even. Therefore, if the index of a triplet is even, its left adjacent triplet is paired, otherwise, the right triplet is paired. April 2012 Segment Tree

44 Run-time Complexity April 2012 Segment Tree

45 April 2012 Segment Tree

46 U’ U” |P(U’)+ P(U”)|=7 U’ U” |P(U’)+ P(U”)|=5 April 2012 Segment Tree

47 April 2012 Segment Tree

48 April 2012 Segment Tree

49 April 2012 Segment Tree

50 April 2012 Segment Tree

51 April 2012 Segment Tree


Download ppt "Segment Tree and Its Usage for geometric Computations"

Similar presentations


Ads by Google