Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. public void nonSortedTree() {
  2.         System.out.print(root.key+" ");
  3.         recursiveNonSortedTree(root.left, root.right);
  4.     }
  5.  
  6.     private void recursiveNonSortedTree(Node left, Node right) {
  7.         if (left != null) {
  8.             System.out.print(left.key+" ");
  9.         }
  10.         if (right != null) {
  11.             System.out.print(right.key+" ");
  12.         }
  13.  
  14.         if (left != null) {
  15.             recursiveNonSortedTree(left.left, left.right);
  16.         }
  17.         if (right != null) {
  18.             recursiveNonSortedTree(right.left, right.right);
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement