词条 | Geometry of binary search trees |
释义 |
In computer science, one approach to the dynamic optimality problem on online algorithms for binary search trees involves reformulating the problem geometrically, in terms of augmenting a set of points in the plane with as few additional points as possible in order to avoid rectangles with only two points on their boundary.[1] Access sequences and competitive ratioAs typically formulated, the online binary search tree problem involves search trees defined over a fixed key set (1, 2, ..., n). An access sequence is a sequence ... where each number xi is one of the given keys. Any particular algorithm for maintaining binary search trees (such as the splay tree algorithm or Iacono's working set structure) has a cost for each access sequence that models the amount of time it would take to use the structure to search for each of the keys in the access sequence in turn. The cost of a search is modeled by assuming that the search tree algorithm has a single pointer into a binary search tree, which at the start of each search points to the root of the tree. The algorithm may then perform any sequence of the following operations:
The search is required, at some point within this sequence of operations to move the pointer to a node containing the key, and the cost of the search is the number of operations that are performed in the sequence. The total cost costA(X) for algorithm A on access sequence X is the sum of the costs of the searches for each successive key in the sequence. As is standard in competitive analysis, the competitive ratio of an algorithm A is defined to be the maximum, over all access sequences, of the ratio of the cost for A to the best cost that any algorithm could achieve: The dynamic optimality conjecture states that splay trees have constant competitive ratio, but this remains unproven. The geometric view of binary search trees provides a different way of understanding the problem that has led to the development of alternative algorithms that could also (conjecturally) have a constant competitive ratio. Translation to a geometric point setIn the geometric view of the online binary search tree problem, an access sequence (sequence of searches performed on a binary search tree (BST) with a key set ) is mapped to the set of points , where X-axis represents key space and Y-axis represents time; to which a set of touched nodes is added. By touched nodes we mean the following. Consider a BST access algorithm with a single pointer to a node in the tree. At the beginning of an access to a given key , this pointer is initialized to the root of the tree. Whenever the pointer moves to or is initialized to a node, we say that the node is touched.[2] We represent a BST algorithm for a given input sequence by drawing a point for each item that gets touched. For example, assume the following BST on 4 nodes is given: The key set is {1, 2, 3, 4}. {{double image|right|Geometrical view of binary search trees - access sequence only.jpg|275|Geometrical view of binary search trees - access sequence.jpg|275|Mapping of the access sequence 3, 1, 4, 2 only.|A geometric view of binary search tree algorithm.}}Let 3, 1, 4, 2 be the access sequence.
The touches are represented geometrically: If an item x is touched in the operations for the ith access, then a point (x,i) is plotted. {{clear}}Arborally satisfied point setsA point set is said to be arborally satisfied if the following property holds: for any pair of points that do not both lie on the same horizontal or vertical line, there exists a third point which lies in the rectangle spanned by the first two points (either inside or on the boundary). TheoremA point set containing the points is arborally satisfied if and only if it corresponds to a valid BST for the input sequence . ProofFirst, prove that the point set for any valid BST algorithm is arborally satisfied. Consider points and , where {{mvar|x}} is touched at time {{mvar|i}} and {{mvar|y}} is touched at time {{mvar|j}}. Assume by symmetry that and . It needs to be shown that there exists a third point in the rectangle with corners as and . Also let denote the lowest common ancestor of nodes {{mvar|a}} and {{mvar|b}} right before time {{mvar|t}}. There are a few cases:
Next, show the other direction: given an arborally satisfied point set, a valid BST corresponding to that point set can be constructed. Organize our BST into a treap which is organized in heap-order by next-touch-time. Note that next-touch-time has ties and is thus not uniquely defined, but this isn’t a problem as long as there is a way to break ties. When time {{mvar|i}} reached, the nodes touched form a connected subtree at the top, by the heap ordering property. Now, assign new next-touch-times for this subtree, and rearrange it into a new local treap. If a pair of nodes, {{mvar|x}} and {{mvar|y}}, straddle the boundary between the touched and untouched part of the treap, then if {{mvar|y}} is to be touched sooner than {{mvar|x}} then is an unsatisfied rectangle because the leftmost such point would be the right child of {{mvar|x}}, not {{mvar|y}}. {{clear}}CorollaryFinding the best BST execution for the input sequence is equivalent to finding the minimum cardinality superset of points (that contains the input in geometric representation) that is arborally satisfied. The more general problem of finding the minimum cardinality arborally satisfied superset of a general set of input points (not limited to one input point per {{mvar|y}} coordinate), is known to be NP-complete.[1] Greedy algorithmThe following greedy algorithm constructs arborally satisfiable sets:
The algorithm has been conjectured to be optimal within an additive term.[3] Other resultsThe geometry of binary search trees has been used to provide an algorithm which is dynamically optimal if any binary search tree algorithm is dynamically optimal.[4] See also
References1. ^1 {{Citation |title=The geometry of binary search trees |first1=Erik D. | last1=Demaine | author1-link = Erik Demaine|first2=Dion | last2=Harmon |first3=John | last3=Iacono | author3-link=John Iacono|first4=Daniel | last4=Kane | author4-link=Daniel Kane (mathematician)|first5=Mihai | last5=Pătraşcu | author5-link=Mihai Pătraşcu|year=2009 |journal=in Proceedings of the 20th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2009) |url=http://erikdemaine.org/papers/BST_SODA2009/|doi=10.1137/1.9781611973068.55|location=New York | pages=496–505}} 2. ^{{Citation |title=Dynamic optimality—almost|first1=Erik D. | last1=Demaine | author1-link = Erik Demaine|first2=Dion | last2=Harmon |first3=John | last3=Iacono | author3-link=John Iacono|first4=Mihai | last4=Pătraşcu | author4-link = Mihai Pătraşcu|year=2007 | journal=SIAM Journal on Computing|volume=37|number=1|doi = 10.1137/S0097539705447347 | mr = 2306291 | url = http://erikdemaine.org/papers/Tango_SICOMP/|pages=240–251|citeseerx=10.1.1.99.4964}} 3. ^{{Cite conference |title=Upper bounds for maximally greedy binary search trees|first1=Kyle |last1=Fox|date=August 15–17, 2011|conference=Algorithms and Data Structures: 12th International Symposium, WADS 2011 |location=New York|publisher=Springer |series=Lecture Notes in Computer Science |volume=6844 |doi=10.1007/978-3-642-22300-6_35|url=http://web.engr.illinois.edu/~kylefox2/publications/greedyfuture.pdf |pages=411–422|arxiv=1102.4884}} 4. ^{{Cite journal |doi=10.1007/978-3-642-40273-9_16 |title=In Pursuit of the Dynamic Optimality Conjecture |journal=Space-Efficient Data Structures, Streams, and Algorithms |volume=8066 |pages=236–250 |series=Lecture Notes in Computer Science |year=2013 |last=Iacono |first=John |authorlink=John Iacono |isbn=978-3-642-40272-2 |arxiv=1306.0207 |bibcode=2013arXiv1306.0207I}} 2 : Binary trees|Geometry |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。