def Cumfreq(symbol, dictionary):
  """
  This Function Takes as  inputs a symbol and a dictionary containing
  all the symbols that exists in our stream and their frequencies 
  and returns the cumulative frequency starting from the very 
  beginning of the Dictionary until that Symbol.
  
  Arguments:
      symbol {[type]} -- [the symbol we want to get the cumulative frequency for]
      dictionary {[type]} -- [the dictionary that contains the frequency of all symbols]
  Returns:
      p int -- [the upper bound ,which is the sum of all frequencies from the beginning of the dictionary till the specified symbol]
  """

  P = 0
  for sym in dictionary:
      P += dictionary[sym]
      if sym == symbol:
        break
  return P