How would I remove a node of a binary tree that is unsorted, meaning it is not a
ID: 3653196 • Letter: H
Question
How would I remove a node of a binary tree that is unsorted, meaning it is not a search tree and not balanced (no ordering of nodes by value). It has a structure like so...
I beleive I am going to have to do some checking and move pointers but I am unsure as to how to go about it. I don't beleive there is a need to compare each node value like they do in a Binary SEARCH tree so I am unsure as to how to go about it.
Explanation / Answer
To remove a node u have to point to the next node. Suppose u have an array of nodes then simply change node[i]->left = node[i+1] and node[j].right = node [i+2] use appropriate nodes instead of node[i+1] and node [i+2]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.