Binary search tree: Difference between revisions

Content deleted Content added
Editing caption of Fig 1, which previously said "The leaves are not drawn", when they are in fact displayed (i.e. the nodes with values 1, 4, 7 and 13 are all leaves).
Update deletion pseudocode to match diagrams and other snippets
Line 166:
|- 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 := BST-Successor(D)
8 '''if''' EY.parent ≠ 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'''
|-