0

if A is taller than B, but shorter than C. D is taller than B, but shorter than A. Print the persons in descending order of height. How can we solve this by code ?

I referred to Comparison-based ranking algorithm, Simple ranking algorithm

I understand that the ELO rating algorithm could help solve this problem. But ELO algoritm seems like doing over work for a much simpler problem. Is there any other well known algorithm for such kind of questions ?

Input :
AtB -> A is taller than B
AsC -> A is shorter than C
DtB -> D is taller than B
DsA -> D is shorter than A

Expected Output :
CADB
Shubham Kadlag
  • 2,248
  • 1
  • 13
  • 32
  • Which data structure do you assume for the inputs that should be compared to each other? The easiest way would be to store all elements in the same data structure like an array, and perform a quicksort algorithm. However, if you have to compare multiple "data sources" gradually, then **linear optimization** would be a feasible topic to perform what you would like to achieve. – SparkFountain Sep 03 '19 at 12:43
  • We can assume any data structure as we can parse the input to manipulate as want. I didn't quite understand your approach. Could you try to code out your approach for this problem? – Shubham Kadlag Sep 03 '19 at 17:01

0 Answers0