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.

If you hover of the submission results that failed, there will be a popup that appears, where you can download both the input and expected output for that test case.

You appear to have the correct output, but in the wrong order. The solution wants it "left-to-right" (which just so happens to be least-to-greatest since these are apparently
binary search trees).

The root is 47 (the first node given), the rest are input as a binary search tree, which means 2 is the left child of 47. 40 is the right child of 2 (because it's less than 47 but greater than 2), 20 is the left child of 40 (less than 47, greater than 2, and less than 40)...etc.

## Tree : Top View

You are viewing a single comment's thread. Return to all comments →

can anyone explain how to represent the tree for this input, 47 2 40 20 38 30 14 28 10 16 19 44 39 27 7 9 31 12 43 21 5 41 34 49 13 33 3 4 25 22 29 15 32 35 6 24 23 26 1 11 42 36 37 17 18 8 45 48 50 46 ? what is root of this tree ?

same question.. Expected output: 1 2 47 49 50 My output: 47 2 1 49 50

@niranjan_wad how did you manage to find the output? Since, it does not tell what is your output. do you know what is root of above question ?

If you hover of the submission results that failed, there will be a popup that appears, where you can download both the input and expected output for that test case.

You appear to have the correct output, but in the wrong order. The solution wants it "left-to-right" (which just so happens to be least-to-greatest since these are apparently binary search trees).

Try using TreeMap so the keys will be in sorted order

bro..first print traverse, then print that node. then u get correct order

first traverse,the print that node. u get correct order

The root is 47 (the first node given), the rest are input as a binary search tree, which means 2 is the left child of 47. 40 is the right child of 2 (because it's less than 47 but greater than 2), 20 is the left child of 40 (less than 47, greater than 2, and less than 40)...etc.