Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public int prof(E no, List<E> path){
  2.     Node node = root;
  3.     int prof = 0;
  4.     boolean found = false;
  5.     List<Node> path = new ArrayList<>();
  6.     while(!found){
  7.         if(node.getElement().equals(no)){
  8.             path.add(no);
  9.             found = true;
  10.         }else{
  11.             Node right = root.getLeft();
  12.             Node left = root.getRight();
  13.             if(no > node){
  14.                 prof += 2;
  15.                 path.add(right);
  16.                 node = right;
  17.             }else{
  18.                 prof += 2;
  19.                 path.add(left);
  20.                 node = left;
  21.             }
  22.         }
  23.     }
  24.     return
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement