1def buildTree(tuples) :
2 while len(tuples) > 1 :
3 leastTwo = tuple(tuples[0:2]) # get the 2 to combine
4 theRest = tuples[2:] # all the others
5 combFreq = leastTwo[0][0] + leastTwo[1][0] #enter code here the branch points freq
6 tuples = theRest + [(combFreq,leastTwo)] # add branch point to the end
7 tuples.sort() # sort it into place
8 return tuples[0] # Return the single tree inside the list
9