Search code examples
c++indexingdata-structuresrankingrank

What can I use as data structure for Ranking in C++?


I have data-set with these attributes:

  • UserID (int)
  • Group (int)
  • Score (int)

I want to evaluate ranking:

  1. All Ranking by score
  2. Group ranking in user's group by score

What should I do?


Solution

  • Use a linear array of structure which contains the data set and an array of size equal to the number of groups.

    Sort the structure array based on score to get overall rank and use the second array to keep count of the number of structures of each group to assign group rank to each data set.

    struct user
    {
        int userID , group , score;
        int totalRank , groupRank;
    }
    

    Take arrays as:

    user list[100];
    int groupCount[10];    //Assuming there will be maximum 10 groups