Search code examples
listalgorithmsortingcomparisonranking

What is the most efficient way to rank the item of a list based on the preference of the user by showing two item at a time?


For some context, I recommend to watch this video from Tom Scott in which he determines what the best "thing" is : https://youtu.be/ALy6e7GbDRQ. I think it will help for the explanation of my question.


Basically I am trying to make an algorithm/program that makes one user rank all the items from a list by choosing which one he likes the most between two items at a time.

For example with the most basic list with 3 items: A, B and C. The order of operations would look like this:

  1. The user is presented with the choice: A or C.
  2. And he prefer C.
  3. The user is presented with the choice: B or C.
  4. And he prefer C.
  5. The user is presented with the choice: A or B.
  6. and he prefer A.

So we know that the ranked order is [C > A > B] in 3 comparisons.

But what if at step 4, the user would have chosen B? We could assume by logic that he prefer B over A before step 5. So we would know that the ranked list would be [B > C > A] in only 2 comparison and it is as accurate as the first situation. Consequently, we can see that the number of steps depends on the user's choices.


So what is the right or most efficient way to rank all the items in the smallest number of comparisons? I thought about literally comparing every possible combination and have a counter for every item that goes up each time an item is selected over the other. But with that way the number of comparisons to do would just grow exponentially depending on the size of the list and it would not be the most efficient way just like in the example above. I also thought about using a simple sort algorithm in which the user would do the comparison "manually" but I am not very familiar with sort algorithm in general.

In Tom Scott's video, the website pick two items at random and he uses such a big pool of user that the problem just corrects itself by probability and statistic and he does not need to worry about having every item being picked equally to be accurate. Since I just want one user to rank the items, I need to find a way to pick the right items to compare to be the most efficient possible (I think). Another difference is that I will not have over 7000 items like in Tom's version. I want to use this to rank for example "All Disney movies", "Certain music genres" or "All Zelda video games" so I am pretty sure that I will have at max maybe around 100 items.

My question is : am I on the right track? Should I use a simple sort algorithm (if yes which one should I use?) or is the only mathematical way to do this effectively is to compare every combination? Or am I missing something that could help me? If I brute force every combination, it will clearly be the most simple and accurate way to rank the items but it will certainly not be the most efficient. I suppose that the order of the comparisons and which items we compare really matter to be the most efficient and this is where I am lost.

I know it is not really a conventional question to ask here but thanks for helping me or orienting me on the right path.


Solution

  • Assuming that the user will create a total ordering of items, the algorithm should maintain a fully ordered list of an increasing number of items. Take the next unordered item and use the comparisons needed for binary search to insert it in the ordered list.

    Take the next unordered item and use binary search comparisons of two items to insert that.

    Repeat until all items are ordered.

    The binary searches should minimise the comparisons at each stage and present the user with more meaningful comparisons over time for each new item.