| 65 | System.out.println(); |
| 66 | } |
| 67 | public static void main(String args[]) { |
| 68 | /* |
| 69 | 1 |
| 70 | / \ |
| 71 | 2 3 |
| 72 | / \ / \ |
| 73 | 4 5 6 7 |
| 74 | |
| 75 | expected output : 4 2 1 3 7 |
| 76 | */ |
| 77 | Node root = new Node(1); |
| 78 | root.left = new Node(2); |
| 79 | root.right = new Node(3); |
| 80 | root.left.left = new Node(4); |
| 81 | root.left.right = new Node(5); |
| 82 | root.right.left = new Node(6); |
| 83 | root.right.right = new Node(7); |
| 84 | |
| 85 | /* |
| 86 | 1 |
| 87 | / \ |
| 88 | 2 3 |
| 89 | \ |
| 90 | 4 |
| 91 | \ |
| 92 | 5 |
| 93 | \ |
| 94 | 6 |
| 95 | |
| 96 | expected output : 2 1 3 6 |
| 97 | */ |
| 98 | Node root2 = new Node(1); |
| 99 | root2.left = new Node(2); |
| 100 | root2.right = new Node(3); |
| 101 | root2.left.right = new Node(4); |
| 102 | root2.left.right.right = new Node(5); |
| 103 | root2.left.right.right.right = new Node(6); |
| 104 | |
| 105 | |
| 106 | topView(root); |
| 107 | topView(root2); |
| 108 | } |
| 109 | } |