We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The input given in the question is in Binary search Insertion type. Like 47 is root node , 2 is smaller than 47 therefore ,on the left side of 47. 40 is smaller than 47 and greater than 2 , therfore 40 is the right child of 2, similarly in this way tree is constructed.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree : Top View
You are viewing a single comment's thread. Return to all comments →
The input given in the question is in Binary search Insertion type. Like 47 is root node , 2 is smaller than 47 therefore ,on the left side of 47. 40 is smaller than 47 and greater than 2 , therfore 40 is the right child of 2, similarly in this way tree is constructed.