Binary search tree: Difference between revisions

Content deleted Content added
Update deletion pseudocode to match diagrams and other snippets
m Fix variable case in deletion to match other snippets
Line 166:
|- style="vertical-align:top"
|
1 BST-Delete(BST, Zz)
2 '''if''' Zz.left = NIL '''then'''
3 Shift-Nodes(BST, Zz, Zz.right)
4 '''else if''' Zz.right = NIL '''then'''
5 Shift-Nodes(BST, Zz, Zz.left)
6 '''else'''
7 Yy := BST-Successor(Dz)
8 '''if''' Y.parent ≠ Zz '''then'''
9 Shift-Nodes(BST, Yy, Yy.right)
10 Yy.right := Zz.right
11 Yy.right.parent := Yy
12 '''end if'''
13 Shift-Nodes(BST, Zz, Yy)
14 Yy.left := Zz.left
15 Yy.left.parent := Yy
16 '''end if'''
|-