"#simple solution
1.firstly find the node in the bst (O(logn) time complexity it take)
2.now removing the node consists of 3 cases:
1.if the node is leaf (no children):
(keep track of parent and do)
parent.left or parent.right=NULL
simply remove the node ()
2.if(has one child) replace the node with its child
3.if has both childs
we replace the node with either inorder predesor(max of left tree)or inorder succesor and remove
the node wh"
Sambangi C. - "#simple solution
1.firstly find the node in the bst (O(logn) time complexity it take)
2.now removing the node consists of 3 cases:
1.if the node is leaf (no children):
(keep track of parent and do)
parent.left or parent.right=NULL
simply remove the node ()
2.if(has one child) replace the node with its child
3.if has both childs
we replace the node with either inorder predesor(max of left tree)or inorder succesor and remove
the node wh"See full answer
Software Engineer
Coding
🧠Want an expert answer to a question? Saving questions lets us know what content to make next.