text: Threaded Binary Search Tree | Deletion | Here ' par ' is pointer to parent Node and ' ptr ' is pointer to current Node . ; Initialize child Node to be deleted has left child . ; Node to be deleted has right child . ; Node to be deleted is root Node . ; Node is left child of its parent . ; Find successor and predecessor ; If ptr has left subtree . ; If ptr has right subtree .
code: static Node caseB ( Node root , Node par , Node ptr ) { Node child ; if ( ptr . lthread == false ) child = ptr . left ; else child = ptr . right ; if ( par == null ) root = child ; else if ( ptr == par . left ) par . left = child ; else par . right = child ; Node s = inSucc ( ptr ) ; Node p = inPred ( ptr ) ; if ( ptr . lthread == false ) p . right = s ; else { if ( ptr . rthread == false ) s . left = p ; } return root ; }