Added a function to calculate the startindexes

Added the function calculateCategoryStartIndex() to calculate the index
where each category starts, and stores them in an array.