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: struct Node * caseB ( struct Node * root , struct Node * par , struct Node * ptr ) { struct 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 ; } free ( ptr ) ; return root ; }