Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /*
  2. class Node
  3. public int frequency; // the frequency of this tree
  4. public char data;
  5. public Node left, right;
  6.  
  7. */
  8.  
  9. void decode(String S ,Node root){
  10. Node temp = root;
  11. for( int i = 0; i < S.length(); i++)
  12. {
  13. if(temp.data != '\0')
  14. {
  15. System.out.println(temp.data);
  16. temp = root;
  17. }
  18. else
  19. {
  20. switch(S.charAt(i))
  21. {
  22. case '0':
  23. System.out.println("moving left");
  24. temp = temp.left;
  25. break;
  26. case '1':
  27. System.out.println("moving right");
  28. temp = temp.right;
  29. break;
  30. default:
  31. break;
  32. }
  33. }
  34. }
  35. }
  36.  
  37. //void decodeHelper(Node)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement