what is the diference between the formuleas used?
the diference between quartiles of ungrouped data and grouped data set
If your data have been grouped in some way, such as summarized into a histogram where you only the bounds of the bins, and not the original values, then you need to use the bin counts to locate the quartile positions.
Since you don't know within a grouped bin where every number falls within that bin (i.e., if you know the bin count is 10 for the bin 20-29, you don't know if it's all 20s, all 29s, or a mix of numbers in varying quantities), you need to determine the midpoint of the bin by calcuting ((upper bound-lower bound)/2) and using that as the assumed value for all members in that bin.
From there you simply use the positional information for median and 1st and 3rd quartiles and determine their location based on a simplified data set which consists only of sets of the median values.
So, in short, the formulas don't change, it's the data set that is modified due to the lack of information you have when presented only with bin bounds and counts-you simply don't know the original data values and have to work with the summary information you've been provided in a histogram.
If I misunderstood your question, please let me know!