0 0 votes Identify the correct sequence for searching 105 in a binary search tree? a. 500,250,190,220,150,120,105 b. 80,800,500,90,270,280,105 c. 20,30,80,200,90,120,105 d. 30,50,80,200,90,120,105 Plz help me. Data Structures data-structures binary-search-tree + – mystylecse 2.4k views answer comment Share Follow Print See all 8 Comments 8 8 Comments reply Show 5 previous comments mystylecse commented Oct 5, 2017 reply Follow flag They are asking which of them is correct sequence. 0 0 replyShare sachin! commented Oct 5, 2017 i edited by sachin! Oct 5, 2017 reply Follow flag ONLY c d 0 0 replyShare mystylecse commented Oct 5, 2017 reply Follow flag Can you please explain only b option why it is correct sequence? 0 0 replyShare Please log in or register to add a comment.
Best answer 2 2 votes Searching in a BST always starts at the root. We compare a data stored at the root with the key we are searching for. If the node does not contain the key we proceed either to the left or right child depending upon the comparison. If the result of the comparison is negative we go to the left child, otherwise - to the right child. You need to check the following conditions: (i) The left sub-tree of a node contains only nodes with keys less than the node's key. (ii) The right sub-tree of a node contains only nodes with keys greater than the node's key. Options C and D are correct sequences for 150. LeenSharma answered Oct 5, 2017 • edited Oct 5, 2017 by LeenSharma LeenSharma comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments LeenSharma commented Oct 5, 2017 reply Follow flag I think all B,C, and D are the correct searching sequence.Why are you saying only C and D right?Please prove your point. 0 0 replyShare Warlock lord commented Oct 5, 2017 reply Follow flag In B) 105 is on the right tree of 270. Is 105>270? 0 0 replyShare LeenSharma commented Oct 5, 2017 reply Follow flag yes, Thank you for correcting. 0 0 replyShare Please log in or register to add a comment.