(Node root,String res)
| 49 | } |
| 50 | |
| 51 | public static void huffmanencode(Node root,String res) |
| 52 | { |
| 53 | if(root.left==null&&root.right==null) |
| 54 | { |
| 55 | System.out.print(res+" "); |
| 56 | return; |
| 57 | } |
| 58 | huffmanencode(root.left,res+"0"); |
| 59 | huffmanencode(root.right,res+"1"); |
| 60 | } |
| 61 | public static class Node |
| 62 | { |
| 63 | String name; |