Binary search tree: Difference between revisions

Content deleted Content added
Deletion: align img
m Removed recurrent information; fixed citations.
 
(45 intermediate revisions by 24 users not shown)
Line 6:
|invented_by=P.F. Windley, [[Andrew Donald Booth|A.D. Booth]], [[Andrew Colin|A.J.T. Colin]], and [[Thomas N. Hibbard|T.N. Hibbard]]
|invented_year=1960
|space_avg={{math|{{math|O(''n'')}}}}
|space_worst={{math|{{math|O(''n'')}}}}
|search_avg={{math|{{math|O(log ''n'')}}}}
|search_worst={{math|{{math|O(''n'')}}}}
|insert_avg={{math|{{math|O(log ''n'')}}}}
|insert_worst={{math|{{math|O(''n'')}}}}
|delete_avg={{math|{{math|O(log ''n'')}}}}
|delete_worst={{math|{{math|O(''n'')}}}}
}}
 
[[File:Binary search tree.svg|right|upright=0.8|thumb|Fig. 1: A binary search tree of size 9 and depth 3, with 8 at the root. The leaves are not drawn.]]
 
In [[computer science]], a '''binary search tree''' ('''BST'''), also called an '''ordered''' or '''sorted binary tree''', is a [[Rooted tree|rooted]] [[binary tree]] [[data structure]] with the key of each internal node being greater than all the keys in the respective node's left subtree and less than the ones in its right subtree. The [[time complexity]] of operations on the binary search tree is [[directlyTime proportionalcomplexity#Linear time|linear]] with respect to the height of the tree.
 
Binary search trees allow [[Binary search algorithm|binary search]] for fast lookup, addition, and removal of data items. Since the nodes in a BST are laid out so that each comparison skips about half of the remaining tree, the lookup performance is proportional to that of [[binary logarithm]]. BSTs were devised in the 1960s for the problem of efficient storage of labeled data and are attributed to [[Conway Berners-Lee]] and [[David_Wheeler_(computer_scientist)|David Wheeler]].
Line 24:
The performance of a binary search tree is dependent on the order of insertion of the nodes into the tree since arbitrary insertions may lead to degeneracy; several variations of the binary search tree can be built with guaranteed worst-case performance. The basic operations include: search, traversal, insert and delete. BSTs with guaranteed worst-case complexities perform better than an unsorted array, which would require [[linear time|linear search time]].
 
The [[Computational complexity theory|complexity analysis]] of BST shows that, [[Best, worst and average case|on average]], the insert, delete and search takes <math>O(\log n)</math> for <math>n</math> nodes. In the worst case, they degrade to that of a singly linked list: <math>O(n)</math>. To address the boundless increase of the tree height with arbitrary insertions and deletions, [[Self-balancing_binary_search_tree|self-balancing]] variants of BSTs are introduced to bound the worst lookup complexity to that of the binary logarithm. [[AVL trees]] were the first self-balancing binary search trees, invented in 1962 by [[Georgy Adelson-Velsky]] and [[Evgenii Landis]].<ref>{{cite web |last=Pitassi |first=Toniann |year=2015 |title=CSC263: Balanced BSTs, AVL tree |url=http://www.cs.toronto.edu/~toni/Courses/263-2015/lectures/lec04-balanced-augmentation.pdf |url-status=live |archive-url=https://web.archive.org/web/20190214212633/http://www.cs.toronto.edu/~toni/Courses/263-2015/lectures/lec04-balanced-augmentation.pdf |archive-date=14 February 2019 |access-date=19 May 2022 |publisher=[[University of Toronto]], Department of Computer Science |page=6}}</ref><ref>{{cite web |last=Myers |first=Andrew |title=CS 312 Lecture: AVL Trees |url=https://www.cs.cornell.edu/courses/cs312/2008sp/lectures/lec_avl.html |url-status=live |archive-url=https://web.archive.org/web/20210427195749/http://www.cs.cornell.edu/courses/cs312/2008sp/lectures/lec_avl.html |archive-date=27 April 2021 |access-date=19 May 2022 |publisher=[[Cornell University]], Department of Computer Science}}</ref><ref>{{cite journal |last1=Adelson-Velsky |first1=Georgy |last2=Landis |first2=Evgenii |year=1962 |title=An algorithm for the organization of information |journal=[[Proceedings of the USSR Academy of Sciences]] |language=ru |volume=146 |pages=263–266}} [https://zhjwpku.com/assets/pdf/AED2-10-avl-paper.pdf English translation] by Myron J. Ricci in ''Soviet Mathematics - Doklady'', 3:1259–1263, 1962.</ref>
 
Binary search trees can be used to implement [[abstract data type]]s such as [[Set (abstract data type)|dynamic sets]], [[lookup table]]s and [[priority queues]], and used in [[sorting algorithm]]s such as [[tree sort]].
 
==History==
The binary search tree algorithm was discovered independently by several researchers, including P.F. Windley, [[Andrew Donald Booth]], [[Andrew Colin]], [[Thomas N. Hibbard]].<ref name="computer_journal89">{{cite journal|journal=[[The Computer Journal]]|date=1 January 1989|doi=10.1093/comjnl/32.1.68|volume=32|issue=1|pages=68–69|first1=J.|last1=Culberson|first2=J. I.|last2=Munro|url=https://academic.oup.com/comjnl/article/32/1/68/341965?login=true|doi-access=free|title=Explaining the Behaviour of Binary Search Trees Under Prolonged Updates: A Model and Simulations}}</ref><ref>{{cite journal|journal=[[Algorithmica]]|publisher=[[Springer Publishing]], [[University of Waterloo]]|title= Analysis of the standard deletion algorithms in exact fit ___domain binary search trees|date=28 July 1986|doi=10.1007/BF01840390|url=https://link.springer.com/article/10.1007%2FBF01840390|first1=J.|last1=Culberson|first2=J. I.|last2=Munro|volume=5 |issue=1–4 |page=297|s2cid=971813 |url-access=subscription}}</ref> The algorithm is attributed to [[Conway Berners-Lee]] and [[David Wheeler (computer scientist)|David Wheeler]], who used it for storing [[labeled data]] in [[magnetic tape]]s in 1960.<ref name="windley60">{{cite journal|journal=[[The Computer Journal]]|date=1 January 1960|doi=10.1093/comjnl/3.2.84|url=https://academic.oup.com/comjnl/article/3/2/84/504799|author=P. F. Windley|volume=3|issue=2|page=84|title= Trees, Forests and Rearranging|doi-access=free|url-access=subscription}}</ref> One of the earliest and popular binary search tree algorithm is that of Hibbard.<ref name="computer_journal89" />
 
The time complexities of a binary search tree increases boundlessly with the tree height if the nodes are inserted in an arbitrary order, therefore [[self-balancing binary search tree]]s were introduced to bound the height of the tree to <math>O(\log n)</math>.<ref name="Knuth98">{{cite book|title=The Art of Computer Programming|first=Donald|last=Knuth|author-link=Donald_Knuth|publisher=[[Addison-Wesley]]|year=1998|chapter=Section 6.2.3: Balanced Trees|pages=458–481|volume=3|edition=2|url=https://ia801604.us.archive.org/17/items/B-001-001-250/B-001-001-250.pdf |archive-url=https://ghostarchive.org/archive/20221009/https://ia801604.us.archive.org/17/items/B-001-001-250/B-001-001-250.pdf |archive-date=2022-10-09 |url-status=live|isbn=978-0201896855
}}</ref> Various '''height-balanced''' binary search trees were introduced to confine the tree height, such as [[AVL tree]]s, [[Treap]]s, and [[red–black tree]]s.<ref>Paul E. Black, "red-black tree", in Dictionary of Algorithms and Data Structures [online], Paul E. Black, ed. 12 November 2019. (accessed May 19 2022) from: https://www.nist.gov/dads/HTML/redblack.html</ref>
 
The AVL tree was invented by [[Georgy Adelson-Velsky]] and [[Evgenii Landis]] in 1962 for the efficient organization of information.<ref>{{cite web|url=https://www.cs.cornell.edu/courses/cs312/2008sp/lectures/lec_avl.html|publisher=[[Cornell University]], Department of Computer Science|access-date=19 May 2022|title=CS 312 Lecture: AVL Trees|first=Andrew|last=Myers|url-status=live|archive-url=https://web.archive.org/web/20210427195749/http://www.cs.cornell.edu/courses/cs312/2008sp/lectures/lec_avl.html|archive-date=27 April 2021}}</ref><ref>{{cite journal|last1=Adelson-Velsky|first1=Georgy|last2=Landis|first2=Evgenii|year=1962|title=An algorithm for the organization of information|journal=[[Proceedings of the USSR Academy of Sciences]]|volume=146|pages=263–266|language=ru}} [https://zhjwpku.com/assets/pdf/AED2-10-avl-paper.pdf English translation] by Myron J. Ricci in ''Soviet Mathematics - Doklady'', 3:1259–1263, 1962.</ref> It was the first self-balancing binary search tree to be invented.<ref>{{cite web|url=http://www.cs.toronto.edu/~toni/Courses/263-2015/lectures/lec04-balanced-augmentation.pdf|access-date=19 May 2022|url-status=live|archive-url=https://web.archive.org/web/20190214212633/http://www.cs.toronto.edu/~toni/Courses/263-2015/lectures/lec04-balanced-augmentation.pdf|title=CSC263: Balanced BSTs, AVL tree|first=Toniann|last=Pitassi|year=2015|publisher=[[University of Toronto]], Department of Computer Science|archive-date=14 February 2019|page=6}}</ref>
 
The time complexitiescomplexity of a binary search tree increases boundlessly with the tree height if the nodes are inserted in an arbitrary order, therefore [[self-balancing binary search tree]]s were introduced to bound the height of the tree to <math>O(\log n)</math>.<ref name="Knuth98">{{cite book|title=The Art of Computer Programming|first=Donald|last=Knuth|author-link=Donald_KnuthDonald Knuth|publisher=[[Addison-Wesley]]|year=1998|chapter=Section 6.2.3: Balanced Trees|pages=458–481|volume=3|edition=2|url=https://ia801604.us.archive.org/17/items/B-001-001-250/B-001-001-250.pdf |archive-url=https://ghostarchive.org/archive/20221009/https://ia801604.us.archive.org/17/items/B-001-001-250/B-001-001-250.pdf |archive-date=2022-10-09 |url-status=live|isbn=978-0201896855
}}</ref> Various '''height-balanced''' binary search trees were introduced to confine the tree height, such as [[AVL tree]]s, [[Treap]]s, and [[red–black tree]]s.<ref>Paul E. Black, "red-black tree", in Dictionary of Algorithms and Data Structures [online], Paul E. Black, ed. 12 November 2019. (accessed May 19 2022) from: https://www.nist.gov/dads/HTML/redblack.html</ref>
==Overview==
A binary search tree is a rooted binary tree in which the nodes are arranged in [[total order#Strict and non-strict total orders|strict total order]] in which the nodes with keys greater than any particular node ''A'' is stored on the right [[Tree (data structure)#Terminology|sub-trees]] to that node ''A'' and the onesnodes with keys equal to or less than ''A'' are stored on the left sub-treetrees to ''A,'' satisfying the [[binary search]] property.<ref name="reema18">{{cite book|title= Data Structures Using C|date=13 October 2018|edition=2|first=Reema|last=Thareja|publisher=[[Oxford University Press]]|url=https://global.oup.com/academic/product/data-structures-using-c-9780198099307|isbn= 9780198099307|url-access=subscription|chapter=Hashing and Collision}}</ref>{{rp|p=298}}<ref name="algo_cormen">{{cite book|last1=Cormen|first1=Thomas H. |author-link1=Thomas H. Cormen|last2=Leiserson|first2=Charles E. |author-link2=Charles E. Leiserson|last3=Rivest|first3=Ronald L. |author-link3=Ronald L. Rivest|author-link4=Clifford Stein|first4=Clifford |last4=Stein|url=https://mitpress.mit.edu/books/introduction-algorithms-second-edition|title=Introduction to Algorithms|edition=2nd|year=2001|publisher=[[MIT Press]]|isbn=0-262-03293-7}}</ref>{{rp|287}}
 
Binary search trees are also efficacious in [[sorting algorithm|sorting]]s and [[search algorithm]]s. However, the search complexity of a BST depends upon the order in which the nodes are inserted and deleted; since in worst case, successive operations in the binary search tree may lead to degeneracy and form a [[singly linked list]] (or "unbalanced tree") like structure, thus has the same worst-case complexity as a [[linked list]].<ref>{{cite journal|journal=[[The Computer Journal]]|volume=25|issue=1|date=1 February 1982|doi=10.1093/comjnl/25.1.158|author1=R. A. Frost|author2=M. M. Peterson|page=158|url=https://academic.oup.com/comjnl/article/25/1/158/527326|publisher=[[Oxford University Press]]|title=A Short Note on Binary Search Trees|url-access=subscription}}</ref>{{r|reema18|p=299-302}}
 
Binary search trees are also a fundamental data structure used in construction of [[abstract data structures]] such as sets, [[set (computer science)#Multiset|multisets]], and [[associative array]]s.
Line 47 ⟶ 44:
Searching in a binary search tree for a specific key can be programmed [[recursion (computer science)|recursively]] or [[iteration#Computing|iteratively]].
 
Searching begins by examining the [[tree (data structure)#root nodes|root node]]. If the tree is [[Null pointer|{{math|{{text|nil}}}}]], the key being searched for does not exist in the tree. Otherwise, if the key equals that of the root, the search is successful and the node is returned. If the key is less than that of the root, the search proceeds by examining the left subtree. Similarly, if the key is greater than that of the root, the search proceeds by examining the right subtree. This process is repeated until the key is found or the remaining subtree is <math>\text{nil}</math>. If the searched key is not found after a <math>\text{nil}</math> subtree is reached, then the key is not present in the tree.{{r|algo_cormen|pp=290-291}}
 
====Recursive search====
Line 71 ⟶ 68:
|
Iterative-Tree-Search(x, key)
'''while''' x &ne; NIL '''and''' key &ne; x.key '''thendo'''
'''if''' key < x.key '''then'''
x := x.left
Line 83 ⟶ 80:
 
====Successor and predecessor====
For certain operations, given a node <math>\text{x}</math>, finding the successor or predecessor of <math>\text{x}</math> is crucial. Assuming all the keys of thea BST are distinct, the successor of a node <math>\text{x}</math> in a BST is the node with the smallest key greater than <math>\text{x}</math>'s key. On the other hand, the predecessor of a node <math>\text{x}</math> in a BST is the node with the largest key smaller than <math>\text{x}</math>'s key. FollowingThe isfollowing pseudocode for findingfinds the successor and predecessor of a node <math>\text{x}</math> in a BST.<ref>{{cite web|url=https://ranger.uta.edu/~huang/teaching/CSE5311/CSE5311_Lecture10.pdf|archive-url=https://web.archive.org/web/20210413045057/http://ranger.uta.edu/~huang/teaching/CSE5311/CSE5311_Lecture10.pdf|archive-date=13 April 2021|page=12|publisher=[[University of Texas at Arlington]]|access-date=17 May 2021|url-status=live|title=Design and Analysis of Algorithms|author=Junzhou Huang}}</ref><ref>{{cite web |author=Ray |first=Ray |title=Binary Search Tree |url=https://cs.lmu.edu/~ray/notes/binarysearchtrees/ |access-date=17 May 2022 |publisher=[[Loyola Marymount University]], Department of Computer Science}}</ref><ref name="algo_cormen" />{{rp|292–293}}
{|
|- style="vertical-align:top"
|
BST-Successor(x)
'''if''' x.right &ne; NIL '''then'''
'''return''' BST-Minimum(x.right)
'''end if'''
y := x.parent
'''while''' y &ne; NIL '''and''' x = y.right '''thendo'''
x := y
y := y.parent
'''repeat'''
'''return''' y
|
BST-Predecessor(x)
'''if''' x.left &ne; NIL '''then'''
'''return''' BST-Maximum(x.left)
'''end if'''
y := x.parent
'''while''' y &ne; NIL '''and''' x = y.left '''thendo'''
x := y
y := y.parent
'''repeat'''
'''return''' y
|}
Operations such as finding a node in a BST whose key is the maximum or minimum are critical in certain operations, such as determining the successor and predecessor of nodes. Following is the pseudocode for the operations.<ref name="algo_cormen" />{{rp|291–292}}
Line 114 ⟶ 111:
|
BST-Maximum(x)
'''while''' x.right &ne; NIL '''thendo'''
x := x.right
'''repeat'''
'''return''' x
|
BST-Minimum(x)
'''while''' x.left &ne; NIL '''thendo'''
x := x.left
'''repeat'''
'''return''' x
|}
 
Line 154 ⟶ 151:
 
===Deletion===
[[File:BST node deletion.png|thumb|400px|right|Binary search tree node deletion process.]]
Deletion of a node, say <math>\text{D}</math>, from a binary search tree <math>\text{BST}</math> should abide three cases:{{r|algo_cormen|p=295}}
#The Ifdeletion <math>\text{D}</math> isof a leaf node, the parent node′s pointer tosay <math>\text{DZ}</math>, getsfrom replacedthe withbinary search tree <math>\text{NILBST}</math> andhas consequentlythree <math>\textcases:{D{r|algo_cormen|p=295-297}}</math> gets removed from the tree.
# If <math>\text{DZ}</math> hasis a single childleaf node, theit childis getsreplaced elevatedby as either left or right child of {{nowrap|<math>\text{DNIL}</math>′s}} parent depending on the position of <math>\text{D}</math> within the BST, as shown in fig. 2 part (a) and part (b), and as a result, <math>\text{D}</math> gets removed from the tree.
# If <math>\text{DZ}</math> has bothonly a left and rightone child, the successorchild node of <math>\text{DZ}</math> (letgets itelevated beby modifying the parent node of <math>\text{EZ}</math> whichto canpoint notto have a leftthe child) takesnode, theconsequently position oftaking <math>\text{DZ}</math>'s position in the tree., Thisas dependsshown onin the(b) positionand of <math>\text{E}</math> within <math>\text{BST}</math>:{{r|algo_cormen|p=296}}(c).
## If <math>\text{EZ}</math> ishas {{nowrap|<math>\text{D}</math>′s}}both immediateleft and right childchildren, the [[Tree_traversal#In-order,_LNR|in-order]] successor of <math>\text{EZ}</math>, gets elevated andsay <math>\text{EY}</math>′s, leftdisplaces child pointer is made point to {{nowrap|<math>\text{DZ}</math>′s}} initial left sub-tree, as shown inby fig.following 2the parttwo (c).cases:
## If <math>\text{EY}</math> is not the immediate right child of <math>\text{DZ}</math>,'s deletionright proceedschild, byas replacingshown the position of <math>\text{E}</math> by {{nowrap|<math>\text{E}</math>′s}} right childin (here <math>\text{F}</math>d), and <math>\text{EY}</math> takes the position ofdisplaces <math>\text{DZ}</math> inand <math>\text{BSTY}</math>,'s asright shownchild remain hereunchanged.
## If <math>\text{Y}</math> lies within <math>\text{Z}</math>'s right subtree but is not <math>\text{Z}</math>'s right child, as shown in (e), <math>\text{Y}</math> first gets replaced by its own right child, and then it displaces <math>\text{Z}</math>'s position in the tree.
[[File:AVL-tree-delete.svg|600px|The node <math>\text{D}</math> to be deleted has 2 children]]
# Alternatively, the in-order predecessor can also be used.
{{clear}}
 
The following pseudocode implements the deletion operation in a binary search tree.{{r|algo_cormen|p=296-298}}
{|
|- style="vertical-align:top"
|
1 BST-Delete(BST, Dz)
2 '''if''' Dz.left = NIL '''then'''
3 Shift-Nodes(BST, Dz, Dz.right)
4 '''else if''' Dz.right = NIL '''then'''
5 Shift-Nodes(BST, Dz, Dz.left)
6 '''else'''
7 Ey := TreeBST-Successor(Dz)
8 '''if''' Ey.parent &ne; Dz '''then'''
9 Shift-Nodes(BST, Ey, Ey.right)
10 Ey.right := Dz.right
11 Ey.right.parent := Ey
12 '''end if'''
13 Shift-Nodes(BST, Dz, Ey)
14 Ey.left := Dz.left
15 Ey.left.parent := Ey
16 '''end if'''
|-
|
1 Shift-Nodes(BST, u, v)
Line 195 ⟶ 194:
10 '''end if'''
|}
The <math>\text{TreeBST-Delete}</math> procedure deals with the 3 special cases mentioned above. Lines 2-3 deal with case 1; lines 4-5 deal with case 2 and lines 6-16 for case 3. The [[helper function]] <math>\text{Shift-Nodes}</math> is used within the deletion algorithm for the purpose of replacing the node <math>\text{u}</math> with <math>\text{v}</math> in the binary search tree <math>\text{BST}</math>.{{r|algo_cormen|p=298}} This procedure handles the deletion (and substitution) of <math>\text{u}</math> from <math>\text{BST}</math>.
 
==Traversal==
Line 201 ⟶ 200:
{{see also|Threaded binary tree}}
A BST can be [[Tree traversal|traversed]] through three basic algorithms: [[inorder traversal|inorder]], [[pre-order traversal|preorder]], and [[post-order traversal|postorder]] tree walks.<ref name="algo_cormen" />{{rp|287}}
*'''Inorder tree walk''': Nodes from the left subtree get visited first, followed by the root node and right subtree. Such a traversal visits all the nodes in the order of non-decreasing key sequence.
*'''Preorder tree walk''': The root node gets visited first, followed by left and right subtrees.
*'''Postorder tree walk''': Nodes from the left subtree get visited first, followed by the right subtree, and finally, the root.
 
Following is a recursive implementation of the tree walks.<ref name="algo_cormen" />{{rp|287–289}}
Line 236 ⟶ 235:
 
=== Height-balanced trees ===
A tree is height-balanced if the heights of the left sub-tree and right sub-tree are guaranteed to be related by a constant factor. This property was introduced by the [[AVL tree]] and continued by the [[Red-Blackred–black tree]].{{r|peter11|pp=50-51}} The heights of all the nodes on the path from the root to the modified leaf node have to be observed and possibly corrected on every insert and delete operation to the tree.{{r|peter11|pp=52}}
 
=== Weight-balanced trees ===
Line 243 ⟶ 242:
 
=== Types ===
There are several self-balanced binary search trees, including [[T-tree]],<ref>{{cite conference|url=https://archive.org/details/verylargedatabas0000inte|first1=Tobin J.|last1=Lehman|first2=Michael J.|last2=Carey|title=A Study of Index Structures for Main Memory Database Management Systems|___location=Kyoto|date=25–28 August 1986|conference=Twelfth International Conference on Very Large Databases (VLDB 1986)|isbn=0-934613-18-4|url-access=registration}}</ref> [[treap]],<ref>{{Citation | contribution=Randomized Search Trees | first1=Cecilia R. | last1=Aragon | first2=Raimund | last2=Seidel | title=30th Annual Symposium on Foundations of Computer Science | contribution-url=http://faculty.washington.edu/aragon/pubs/rst89.pdf |archive-url=https://ghostarchive.org/archive/20221009/http://faculty.washington.edu/aragon/pubs/rst89.pdf |archive-date=2022-10-09 |url-status=live | title=Proc. 30th Symp. Foundations of Computer Science (FOCS 1989) | pages=540–545 | year=1989 | doi=10.1109/SFCS.1989.63531 | isbn=0-8186-1982-1 | publisher=IEEE Computer Society Press | ___location=Washington, D.C.| title-link=Symposium on Foundations of Computer Science }}</ref> [[red-black tree]],<ref name="Cormen2001">{{Anchor|Cormen}}{{Cite book |title=Introduction to Algorithms |last1=Cormen |first1=Thomas H. |author1-link=Thomas H. Cormen |last2=Leiserson |first2=Charles E. |author2-link=Charles E. Leiserson |last3=Rivest |first3=Ronald L. |author3-link=Ronald L. Rivest |last4=Stein |first4=Clifford |author4-link=Clifford Stein |edition=second |publisher=MIT Press |year=2001 |isbn=978-0-262-03293-3 |chapter=Red&ndash;Black Trees |pages=[https://archive.org/details/introductiontoal00corm_691/page/n735 273]–301 |title-link=Introduction to Algorithms }}</ref> [[B-tree]],<ref>{{Citation | last = Comer | first = Douglas | author-link = Douglas Comer | title = The Ubiquitous B-Tree | journal = Computing Surveys | volume = 11 | issue = 2 | pages = 123–137 | date = June 1979 | issn = 0360-0300 | doi = 10.1145/356770.356776 | s2cid = 101673 | doi-access = free }}</ref> [[2–3 tree]],<ref>{{cite book| title=The Art of Computer Programming |volume=3| chapter=6.2.4 |quote=The 2–3 trees defined at the close of Section 6.2.3 are equivalent to B-Trees of order 3. |first1=Donald M |last1=Knuth |edition=2 |isbn=9780201896855 |publisher=Addison Wesley|year=1998}}</ref> and [[Splay tree]].<ref>{{cite journal | first1 = Daniel D. | last1 = Sleator | author1-link = Daniel Sleator | first2 = Robert E. | last2 = Tarjan | author2-link = Robert Tarjan | title = Self-Adjusting Binary Search Trees | journal = [[Journal of the ACM]] | volume = 32 | issue = 3 | pages = 652–686 | year = 1985 | url = https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf | doi = 10.1145/3828.3835 | s2cid = 1165848 }}</ref>
 
==Examples of applications==