public static node Huffman(ArrayList<node> list){//Creates tree and returns root
      int n = list.size();
      node x = eMin(list);
      node y = eMin(list);
      node no = new node();
      no.l = x;
      no.r = y;
      no.val = x.val + y.val;
      no.frequency = x.frequency+y.frequency;
      list.add(no);
      
      if(list.size()> 1)
         no = Huffman(list);//recursion
      
      return no;   
  }