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>.