1. 2 3 Segment Trees - motivation.  When one wants to inspect a small portion of a large and complex objects. Example: –GIS: windowing query in a map.

Slides:



Advertisements
Similar presentations
Two Segments Intersect?
Advertisements

WSPD Applications.
INTERVAL TREE & SEGMENTATION TREE
EECS 4101/5101 Prof. Andy Mirzaian. Lists Move-to-Front Search Trees Binary Search Trees Multi-Way Search Trees B-trees Splay Trees Trees Red-Black.
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
Chapter 4: Trees Part II - AVL Tree
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
Dynamic Planar Convex Hull Operations in Near- Logarithmic Amortized Time TIMOTHY M. CHAN.
I/O-Algorithms Lars Arge Fall 2014 September 25, 2014.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
Greedy Algorithms Greed is good. (Some of the time)
1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 20 Prof. Erik Demaine.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
Zoo-Keeper’s Problem An O(nlogn) algorithm for the zoo-keeper’s problem Sergei Bespamyatnikh Computational Geometry 24 (2003), pp th CGC Workshop.
2IL50 Data Structures Spring 2015 Lecture 8: Augmenting Data Structures.
CS 171: Introduction to Computer Science II
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
I/O-Algorithms Lars Arge Aarhus University February 27, 2007.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
1 Geometric Solutions for the IP-Lookup and Packet Classification Problem (Lecture 12: The IP-LookUp & Packet Classification Problem, Part II) Advanced.
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
Lecture 6: Point Location Computational Geometry Prof. Dr. Th. Ottmann 1 Point Location 1.Trapezoidal decomposition. 2.A search structure. 3.Randomized,
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Chapter 10 Search Structures Instructors: C. Y. Tang and J. S. Roger Jang All the material are integrated from the textbook "Fundamentals of Data Structures.
1 Chapter 8 Priority Queues. 2 Implementations Heaps Priority queues and heaps Vector based implementation of heaps Skew heaps Outline.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Orthogonal Range Searching I Range Trees. Range Searching S = set of geometric objects Q = query object Report/Count objects in S that intersect Q Query.
Randomized Algorithms - Treaps
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
UNC Chapel Hill M. C. Lin Point Location Reading: Chapter 6 of the Textbook Driving Applications –Knowing Where You Are in GIS Related Applications –Triangulation.
UNC Chapel Hill M. C. Lin Orthogonal Range Searching Reading: Chapter 5 of the Textbook Driving Applications –Querying a Database Related Application –Crystal.
Modular Decomposition and Interval Graphs recognition Speaker: Asaf Shapira.
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
Introduction Of Tree. Introduction A tree is a non-linear data structure in which items are arranged in sequence. It is used to represent hierarchical.
“On an Algorithm of Zemlyachenko for Subtree Isomorphism” Yefim Dinitz, Alon Itai, Michael Rodeh (1998) Presented by: Masha Igra, Merav Bukra.
Searching: Binary Trees and Hash Tables CHAPTER 12 6/4/15 Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education,
TECH Computer Science Data Abstraction and Basic Data Structures Improving efficiency by building better  Data Structure Object IN  Abstract Data Type.
14/13/15 CMPS 3130/6130 Computational Geometry Spring 2015 Windowing Carola Wenk CMPS 3130/6130 Computational Geometry.
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
Lars Arge Presented by Or Ozery. I/O Model Previously defined: N = # of elements in input M = # of elements that fit into memory B = # of elements per.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
Starting at Binary Trees
Segment Trees Basic data structure in computational geometry. Computational geometry.  Computations with geometric objects.  Points in 1-, 2-, 3-, d-space.
Interval S = [3,10]  {x | 3 ≤ x ≤ 10} Closed segment S = (3,10)  {x | 3 < x < 10} Opened segment S = [3,3]  {3} Point.
1 Schematization of Networks Rida Sadek. 2 This talk discusses: An algorithm that is studied in the following papers:  S. Cabello, M. de Berg, and M.
CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
May 2012Range Search Algorithms1 Shmuel Wimer Bar Ilan Univ. Eng. Faculty Technion, EE Faculty.
Geometric Data Structures
Chapter 11: Multiway Search Trees
12. Graphs and Trees 2 Summary
PC trees and Circular One Arrangements
(edited by Nadia Al-Ghreimil)
Orthogonal Range Searching and Kd-Trees
ICS 353: Design and Analysis of Algorithms
ICS 353: Design and Analysis of Algorithms
(edited by Nadia Al-Ghreimil)
Trees.
CMPS 3130/6130 Computational Geometry Spring 2017
Switching Lemmas and Proof Complexity
Chapter 12&13: Binary Search Trees (BSTs)
Presentation transcript:

1

2

3 Segment Trees - motivation.  When one wants to inspect a small portion of a large and complex objects. Example: –GIS: windowing query in a map - given a detailed map contains enormous amount of data, the system has to determine efficiently the part of the map corresponding to a specified region (window).

4 Semi dynamic segment trees.  Let I = { [x 1, x 1 ’ ], [x 2, x 2 ’ ], , [x n, x n ’ ] } be a set of n intervals.  Let p 1, p 2, , p m be the list of distinct intervals endpoints, sorted from left to right. The elementary intervals are defined to be : (- , p 1 ), [p 1, p 1 ], (p 1, p 2 ), [p 2, p 2 ],  (p m,  ) p1p1 p2p2 pmpm

5 Constructing a segment tree  A balanced binary tree T. The leaves of T correspond to the elementary intervals (ordered from left to right). The elementary interval in a leaf  is denoted Int(  )  The internal nodes of T correspond to the intervals that are the union of elementary intervals: Int(v) is the union of intervals of its two children.

6 Constructing a segment tree- cont.  Each node or leaf v in T stores the interval Int(v) and a canonical set I(v)  I of intervals. This set contains the intervals [x, x’]  I s.t Int(v)  [x, x’] and Inv(Parent(v))  [x, x’].  Lemma: A segment tree on a set of n intervals uses O(nlogn) storage.

7 Segment tree- example s1s1 s2s2 s5s5 s3s3 s4s4 S5S5 S 2, S 5 S1S1 S1S1 S1S1 S3S3 S4S4 S3S3 S4, S3S4, S3 p1p1 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7

8 Lemma - proof T is a balances binary tree  its height is O(logn). Claim: any interval [x, x’] is stored in the set I(v) for at most two nodes at the same depth of T. proof: Let v1, v2, v3 be three nodes from left to right in same depth. Suppose [x, x’] is at v1 and v3.  [x, x’] spans the interval from left point of Int(v1) to right point of Int(v3), v2 lies between v1, v3  Int(parent(v2))  [x, x’].

9 Lemma - proof. Continue  Any interval is stored at most twice at a given depth of T.  The total amount of storage is O(nlogn). v1v1 v2v2 v3v3

10 Algorithm: Query Segment Tree(V,q x )  Input: the root of a segment tree and a query point q x.  Output: All intervals in the tree containing q x.  Report all intervals in I(v).  If v is not a leaf –then if q x  Int(lc(v)) –then QuerySegmentTree(lc(v), qx) –else QuerySegmentTree(rc(v), qx)

11 Algorithm: Query Segment Tree(V,q x ) - Complexity.  Visit O(logn) nodes in total.  At each node v spend O(1+k v ) time. The intervals containing a query point q x are reported in O(logn+k) time, where k is the number of reported intervals.

12 Algorithm: Constructing a segment tree.  Sort the endpoints of the intervals and get the elementary intervals.  Construct a balanced binary tree on the elementary intervals and determine Int(v) for each v. (bottom-up manner).  Determine the canonical subsets : insert the intervals one by one to T.

13 Algorithm: Insert Segment Tree(V,[x,x’])  Input: the root of a segment tree and an interval.  Output: The interval will be stored in tree. If Inv(v)  [x, x’] then store [x, x’] at v. else if Int(lc(v))  [x, x’]   then InsertSegmentTree(lc(v), [x, x’]) if Inv(rc(v))  [x, x’]   then InsertSegmentTree(rc(v), [x, x’])

14 Algorithm: Insert Segment Tree(V,[x,x’]) - Complexity.  An interval is stored at most twice at each level.  There is at most one node at every level whose interval contains x (the same for x’).  Hence, We visit at most 4 nodes per level. The insertion time is O(logn). Construction time is O(nlogn).

15

16 Introduction  Generalization of union-find problem: copy operation is also supported.  The structure: A bipartite graph with two node sets V 1, V 2 and edges between them.  V 1 form the sets and V 2 form the elements. An edge between v 1  V 1 and v 2  V 2 indicates that v 2 is a member element of the set v 1.

17 Notations  Let  = {S 1,  S m } be a collection of sets.   = {x 1, ,x n } be a collection of elements.  The sets in  are subsets of .  Let  x be the collection of sets that contain an element x.

18 The structure Consists four ingredients:  Set nodes - .  Element nodes - .  Normal nodes - connect sets to elements.  Reversed nodes - connect elements to sets. Whenever there is a path from a set node to an element node, the corresponding element is in the corresponding set.

19 The structure - continue. The following invariant are maintained:  A set node has one outgoing edge.  An element node has one incoming edge.  A normal node has one incoming edge, and at least two outgoing edges.  A reversed node has one outgoing edge and at least two incoming edges.  No edge may go from a reversed node to another reversed node.

20 The structure - continue.  No edge may go from a normal node to another normal node.  There is one unique path from a set node to an element node iff the element is in the set.  Any path in the union-copy structure from a set node to an element node consists of an alternating sequence of normal and reversed nodes. The union copy structure is acyclic.

21 The structure - example S1S1 S2S2 S3S3 S4S4 S5S5 x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 set normal reversed element

22 Defining the operations.  Set-create(S) - create a new empty set in  with name S.  Set-insert(S i,x j ) - (defined when x j  S i ). make S i  S i  {x j }.  Set-destroy(S i ) - remove S i from .  Set-find(S i ) - report all elements in S i.  Set-union(S i,S j ) - (defined when S i, S j disjoint). S i  S i  S j and S j .  Set-copy(S i,S j ) - (defined when S j is empty). S j  S i.  Element-create(x) - create an element x in  and  x  .

23 Defining the operations. Continue  Element-insert(x i, S j ) - (define when x i  S j )  xi  xi  {S j }.  Element-destroy(x i ) - remove x i from  and from all its sets.  Element-find(x i ) - report all sets that contain x i.  Element-union(x i,x j ) - (defined when no set contains them both).  S  xj, S  S  {x i }\{x j }, hence  xi becomes  xi  xj and  xj .  Element-copy(x i,x j ) - (defined when x j in no set). Puts x j in all sets containing x i.

24 Set-insert(S 4,x 2 ) S1S1 S2S2 S3S3 S4S4 S5S5 x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8

25 S3S3 Set-destroy(S 3 ) S1S1 S2S2 S3S3 S4S4 S5S5 x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8

26 Set-union(S 4,S 1 ) S1S1 S2S2 S3S3 S4S4 S5S5 x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8

27 Set-copy(S 5,S 6 ) S1S1 S2S2 S3S3 S4S4 S5S5 x1x1 x2x2 x3x3 x4x4 x5x5 x6x6 x7x7 x8x8 S6S6

28 The structure - notations.  N-UF is a union-find structure represents the normal nodes. Sets in N-UF  normal nodes. Elements in N-UF  outgoing edges.  R-UF is a union-find structure represents the reversed nodes. Sets in N-UF  reversed nodes. Elements in R-UF  incoming edges.

29 Operations N-UF structure supports  N-union(v,w) - Unite the edges of the v and w to become the edges of v. w looses its edges.  N-find(e i ) - Return the normal node of e i.  N-add(v,e i ) - Add edge e i to node v.  N-delete(e i ) - Delete e i from its origin.  N-enumerate(v) - Return all outgoing edges of v.

30 The operations. Set-find(S i )  if out(S i )  nil then Traverse(out(S i ) ) Traverse(e)  case type(dest(e)) of –element: report the element as an answer. –normal: for all e’  N-enumerate(dest(e)) do Traverse(e’ ) –reversed: Traverse(out(R-find(e)))

31 Set-union(S i, S j )  if out(Si)  nil or type(child(S i ))  normal then exchange S i and S j.  if out(Sj)  nil then ready.  else if type(child(S i ))  normal and type(child(S j ))  normal then N-union(child(S i ), child(S j ))  else if type(child(S i ))  normal then N-add(child(S i ), out(S j ))  else // both are reversed or elements. make a normal node v. N-add(v, out(S i ) ) ; N-add(v, out(S j ) ) child(S i )  v ; out(S j )  nil

32 Set-union - examples. SiSi SjSj SiSi SjSj SiSi SjSj SiSi SjSj SiSi SiSi SjSj SjSj v

33 Set-copy(S i, S j )  if out(S i )  nil then ready.  else if type(child(S i ))=reversed then R-add(R-find(out(S i )), out(S j ))  else // type(child(S i ))=normal or element. make a reversed node v. child(v)  child(S i ) R-add(v, out(S i )) R-add(v, out(S j ))

34 Set-copy - examples. SiSi SiSi SjSj SiSi SiSi SjSj v

35 Set-insert(S i, x j )  Make a new edge e  if out(S i )  nil then out(S i )  e  else if type(child(S i ))  normal then N-add(child((S i ), e)  else // type(child(S i )) is reversed or element. Make a normal node v N-add(v, out(S i )) ; N-add(v, e) child(S i ) = v  // now e has an origin.  if in(x j )  nil then in(x j )  e  else if type(parent(x j ))  reversed then R-add(parent(x j ), e)

36 Set-insert(S i, x j ) - continue  else // type(parent(x j )) is normal or set. Make a reversed node w. R-add(w, in(x j ) ); R-add(w, e) parent(xj)  w  // now e has a destination. SiSi SiSi xjxj e v w xjxj

37 Set-destroy(S i )  if out(S i )  nil then case type(child(S i )) of element: in(child(Si))  nil reversed : Restore(out(S i ) ) normal: for all e  N-enumerate(child(S i )) do if type(dest(e))  element then in(dest(e))  nil else //type(dest(e)) is reversed. Restore(e)  remove S i

38 Set-destroy(S i ) - Restore(e)  v  R-find(e)  R-delete(e) from v  if v has only one incoming edge e’ then if type(org(e’))  set or type(child(v))  element then out(v)  e’ else // org(e’) and child(v) types are normal. w  N-find(e’) for all e’’  N-enumerate(child(v)) do N-add(w, e’’ ) remove child(v) remove v

39 Set-destroy(S i ) - examples SiSi v SiSi v e’ w

40 The analysis Theorem Given a collection  of m sets and collection  of n elements, a union copy structure has the following performance: set-create O(1)elm-create O(1) set-insert O(1)elm-insert O(1) set-destroy O(1+k  (F N (n)+F R (m)))elm-destroy O(1+k  (F R (m)+F N (n))) set-findO(1+k  F R (m))elm-findO(1+k  F N (n)) set-unionO(U N (n))elm-unionO(U R (m)) set-copyO(F R (m)) elm-copyO(F N (n))

41 Theorem - proof Any normal node has out degree  n. Any reversed node has in degree  m.  The operations N-find (R ), N-enumerate (R ) operate on sets of size O(n) ( O(m) ). Proof for set-find: If there are k answers, then there are O(k) normal nodes and reversed nodes that have been visited. N-enumerate is linear with the degree of the node  the total time spent on normal nodes is O(k). The time to visit a reversed node is O(F R (m)).  At most O(1+k  F R (m)) time is taken.

42

43 Dynamic segments trees - motivation  With semi-dynamic data structures, new segments may only inserted if their endpoints are chosen from a restricted universe.  When using dynamic segments trees segments may be inserted and deleted freely. Split and concatenate operations are also provided.

44 Defining the operations.  Create(T) - (defined if T does not exist yet). Creates an empty tree T.  Insert(T,[x 1,x 2 ]) - (defined if [x 1,x 2 ]  T). [x 1,x 2 ] is inserted to T.  Delete(T,[x 1,x 2 ]) - (defined if [x 1,x 2 ]  T). [x 1,x 2 ] is deleted from T.  Stabbing-query(T,y) - all segments [x 1,x 2 ] for which x 1  y  x 2 are reported.

45 Defining the operations. Continue  Concatenate(T 1,T 2,T) - (defined if the right endpoint of segment in T 1 is less than the left endpoint of segment in T 2, and T is empty. It makes T  T 1  T 2.T 1 and T 2 are returned empty.  Split(T,T 1,T 2,y) - (Defined if all segments [x 1,x 2 ] in T either y  x 1 or x 2  y, and T 1, T 2 are empty). It makes T 1  {[x 1,x 2 ]; x 2  y},T 2  {[x 1,x 2 ]; y  x 1 } T is returned empty.

46 Weak segment tree - definition.  A w.s.t for a set S of segments consists of a binary tree T, with ordered elementary intervals in its leaves. Each node represents a subset of S, s.t  s  S we have: –s is represented exactly once on every path from the root to a leaf, of which the elementary interval in contained in s. –s is not represented on any other path from the root to a leaf. A traditional segment tree is a w.s.t.

47 Weak segment tree - example. I 1,I 2 I 1 =[1,3] I 2 =[2,3] (-,1) [1,1] (1,2) [2,2] (2,3) [3,3] (3,-) I1I1 I2I2 I1I1 I2I2 I2I2 I 1,I 2 I1I1 I1I1 I1I1

48 The union copy structure for dynamic segment trees  Every node in T corresponds to a set in the union-copy structure.  Every segment corresponds to an element.  The union-copy structure has O(n) sets and O(n) elements.

49 The union copy structure for dynamic segment trees. Continue  We take for the N-UF a union-find structure. (O(1) time for N-union).  For R-UF we take a structure in which R-find takes O(1) (UF(i) structure of La Poutre). Allows : R-find in O(1), R-union in O(  (n)) amortized.

50 The structure. The dynamic segment tree consists of:  A week segment tree noted ST T (RB tree). Every node is augmented with an extra pointer to a set node of the union-copy structure.  A union-copy structure.  A dictionary tree (RB tree) noted D T, storing the set S of segments in its leaves order on increasing (lexicography) left endpoint. Every leaf stores a segment which is an element node of the union-copy structure.

51 Why do we use a w.s.t? S2S2 S2S2 S1S1 S1S1 v u After rotation right at v node u holds S 2 – contradicts the definition of a w.s.t! u v S1S1 S2S2 S2S2 S1S1 S1S2S1S2 u v S2S2 S1S1 S1S2S1S2 S1S2S1S2

52 The solution The auxiliary operation Down(  ). Empty a set S  by shifting  ’s elements to both its children:  Set-create(S’)  Set-copy (S ,S’)  Set-union(S lchild(  ),S’)  Set-union(S rchild(  ),S  )  Set-destroy(S’). // remove the empty set S’. This operation will take O(1)!

53 Insert ([x 1,x 2 ],T)  Add [x 1,x 2 ] to D T.  NewEndpoint(x 1,[x 1,x 2 ])  NewEndpoint(x 2,[x 1,x 2 ])    The node in ST T where the paths to x 1 and to x 2 are split.  for  1 on path from lchild(  ) to leaf of x 1 do if x 1 is in left subtree of  1 then Set-insert(S rchild(  1), [x 1,x 2 ])  for  2 on path from rchild(  ) to leaf of x 2 do if x 2 is in left subtree of  2 then Set-insert(S lchild(  2), [x 1,x 2 ])

54 NewEndpoint (x,[x 1,x 2 ])    The leaf that contains x in ST T.  if Int(  ) is an open interval (a,b) then Int(  )  [x,x] add (a,x) as a leaf  ’ to ST T add (x,b) as a leaf  ’’ to ST T Set-create(S  ’ ) ; Set-create(S  ’’ ) Set-copy(S , S  ’ ) ; Set-copy(S , S  ’’ ) m(  )  0 ;  Set-insert(S ,[x 1,x 2 ]) ; m(  )  m(  ) +1

55 Insert ([x 1,x 2 ],T) - example I 1,I 2 I 1 =[1,3] I 2 =[2,3] (-,1) [1,1] (3,-) I1I1 I2I2 Insert ( [1.5,2.5] ) [2,2] (1.5,2) (1,1.5) [1.5,1.5] [3,3] (2.5,3) (2,2.5) [2.5,2.5] I 3 =[1.5,2.5] I1I1 I3I3 I3I3 I3I3 I3I3 m(  )=1 (1,2) (2,3)

56 Delete([x 1,x 2 ],T)    The leaf in D T that contains [x 1,x 2 ]  Element-destroy(  )  delete [x 1,x 2 ] from D T  Remove-endpoint(x 1 )  Remove-endpoint(x 2 )

57 Remove-endpoint(x)    The leaf in ST T that contains x.  m(  )  m(  ) - 1  if m(  ) = 0 then // let Int(leaf left  )=(a,x) // let Int(leaf right  )=(x,b) Int(  )  (a,b) delete from ST T the leaf left of  delete from ST T the leaf right of 

58 [1.5,1.5] Delete ([x 1,x 2 ],T) - example I 1,I 2 I 1 =[1,3] I 2 =[2,3] (-,1) [1,1] (3,-) I1I1 I2I2 Delete ( [1.5,2.5] ) (1.5,2) (1,1.5) (2.5,3) [2.5,2.5] I 3 =[1.5,2.5] I1I1 I3I3 I3I3 I3I3 I3I3 m(  )=0 (1,1.5) (1.5,2) I3I3 I3I3 I3I3 I3I3 [2.5,2.5] [1.5,1.5] (1,2) (2.5,3) [2,2] (2,3) [3,3] (2,2.5)

59 Concatenate(T 1,T 2,T)  if T 1 is empty then T  T 2 ; ready  if T 2 is empty then T  T 1 ; ready   1  rightmost leaf of ST T1 // let Int(  1 ) = (x,  )   2  leftmost leaf of ST T2 // let Int(  2 ) = (- ,y)  Int(  1 ) = (x,y)  delete  2 from ST T2  concatenate ST T1 and ST T2 to ST T  concatenate D T1 and D T2 to D T

60 Stabbing-query(T,y)  for all nodes  on the path ST T to y do Set-find(S  )

61 The analysis Lemma1: The operations insert and concatenate take O(logn) time on a dynamic segment tree that stores n segments, and this operations increase the space of the structure by at most O(logn).

62 The analysis - Continue. Lemma2: Suppose the union copy-structure (as we chose) has O(nlogn) edges. Then O(n) Element-destroy operations take O(nlogn  (n)) time.

63 The analysis - Continue. Theorem: The operations insert and concatenate on the dynamic segment tree as described above for storing a set of n segments each take O(logn) amortized time. The delete operations take O(logn  (n)) amortized time, and stabbing queries take O(logn+k) time. The structure requires O(nlogn) space and can be constructed in O(nlogn) time.