You are viewing a single comment's thread. Return to all comments →
I came up with a similar solution in Java :) So far, I like it the most.
void top_view(Node root) { top_view(root, 0); } void top_view(Node root, int side) { if (root != null) { if (side <= 0) { top_view(root.left, -1); } System.out.print(root.data + " "); if (side >= 0) { top_view(root.right, 1); } } }
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 →
I came up with a similar solution in Java :) So far, I like it the most.