I've come across two questions from my previous years college test papers. I just couldn't solve them

  1. Define rational number as an ADT (abstract data structure)
  2. Write a suitable C code to sort a finite set of elements where an element may appear a large number of times

For the second question, only the logic would suffice
Thanks in advance!

>Define rational number as an ADT (abstract data structure)
I fail to see how this is difficult. What kept you from completing the exercise?

>Write a suitable C code to sort a finite set of elements
>where an element may appear a large number of times

Well any general sorting algorithm will do this, so now you only need to find one where the processing of duplicate values is efficient. Might I suggest counting sort?

I fail to see how this is difficult

Actually, I just couldn't understand the question.
All I know about rational numbers is that they are Set of Real Numbers minus Set of Irrational Numbers Or another way of defining them is "Any number that can be expressed in p/q format where q≠0 (p & q belong to set of integers)"
But I don't know how to express them as an ADT

>Any number that can be expressed in p/q format where q≠0 (p & q belong to set of integers)
Translation: rational numbers can always be represented by a fraction p/q where q is not zero. So you need to write a common fraction "class":

typedef struct rational {
  int numerator;
  int denominator;
} rational;
This question has already been answered. Start a new discussion instead.