Content deleted Content added
→Traversal: ce; deletion process is complex and already explained in detail in previous section |
Nomen4Omen (talk | contribs) m →Deletion: idea due to Hibbard |
||
Line 157:
# If <math>\text{D}</math> has a single child node, the child gets elevated as either left or right child of {{nowrap|<math>\text{D}</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{D}</math> has both a left and right child, the successor of <math>\text{D}</math> (let it be <math>\text{E}</math> which can not have a left child) takes the position of <math>\text{D}</math> in the tree. This depends on the position of <math>\text{E}</math> within <math>\text{BST}</math>:{{r|algo_cormen|p=296}}
#
#
|last1=Sedgewick
|first1=Robert
|author1-link=Robert Sedgewick (computer scientist)
|last2=Wayne
|first2=Kevin
|title=Algorithms
|edition=4th
|isbn=978-0-321-57351-3
|year=2011
|publisher=Addison-Wesley Professional
|url=http://algs4.cs.princeton.edu}})
the idea of this node exchange is due to T. Hibbard.</ref>
[[File:AVL-tree-delete.svg|600px|The node <math>\text{D}</math> to be deleted has 2 children]]
{{clear}}
|