(5)Root (3)-------^--------(7) (2)---^----(5) ^-----(8)
I want to add node with data 5 in this binary Search tree. Please help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Note: This answer assumes you are talking about a binary search tree.
You traverse the binary tree from the root:
if you arrived at a node, where you can not go any deeper, because there is no subtree, this is the place to insert your new element
You start at
(5), then go left (since 5 <= 5) to(3), then go right (since 5 > 3) to(5), then you want to go to the left subtree (since 5 <= 5), but you see that there is no subtree, so this is the place to insert your new element(5).