Constructing a frequency distribution and a histogram