We are given N objects, out of which exactly one object is of different weight(can be less or more). Also, we are given M comparisons of the following 3 types -
- Weight(Set A) < Weight(Set B)
- Weight(Set A) > Weight(Set B)
- Weight(Set A) = Weight(Set B)
Where Set A and Set B (both have same number of objects) are a list of objects from the initial N objects.
Given M such comparisons, I need to find the object with different weight if possible. Otherwise tell that the given list of M comparisons isn't sufficient to detect the one with different weight.
Can somebody suggest an algorithm for solving this problem?