daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    /*
  2.    
  3.     class Node
  4.        int data;
  5.        Node left;
  6.        Node right;
  7.    */
  8.    void topView(Node root) {
  9.       if (root == null) return;
  10.       printLeft(root);
  11.       printRight(root.right);
  12.    }
  13.    
  14.    void printLeft(Node root) {
  15.        if (root == null) return;
  16.        printLeft(root.left);
  17.        System.out.print(root.data + " ");
  18.    }
  19.  
  20.    void printRight(Node root) {
  21.        if (root == null) return;
  22.        System.out.print(root.data + " ");
  23.        printRight(root.right);
  24.    }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top