public static int gMin(ArrayList<node> list){
      int min = (list.get(0)).frequency;
      int index = 0;
      for(int i=1; i<list.size(); i++){
         if((list.get(i)).frequency < min){
            min = (list.get(i)).frequency;
            index=i;
         }
      }
      return index;
   }