GATE CSE
First time here? Checkout the FAQ!
x
0 votes
62 views

A program P reads the 500 numbers in the range [1, 2, …., 100] to represent the ranks of 500 students. If the program P prints the frequency of each rank above 50, then what would be the best way for P to store the frequencies

  1.   An array of 50 numbers
  2.   An array of 100 numbers
  3.   An array of 500 numbers
  4.   An array of 550 numbers
asked in DS by Active (1.4k points)   | 62 views

1 Answer

+1 vote
Answer should be A.

We have to store frequencies. In the range [1,2, ... , 100] there are 50 numbers which are greater than 50. To store the frequency we can create an integer array, say freq, of 50 elements and then value of

freq[0] denotes the frequency of rank 51,

freq[1] denotes the frequency of rank 52, and so on and finally,

freq[49] denotes the frequency of rank 100

So at the minimum, we need array of 50 elements.
answered by Loyal (3.4k points)  

Related questions

+1 vote
1 answer
1
asked in DS by Shubhanshu Loyal (2.8k points)   | 93 views


Top Users Jul 2017
  1. Bikram

    5368 Points

  2. manu00x

    3092 Points

  3. Arjun

    1924 Points

  4. joshi_nitish

    1898 Points

  5. Debashish Deka

    1874 Points

  6. pawan kumarln

    1454 Points

  7. Tesla!

    1390 Points

  8. Hemant Parihar

    1314 Points

  9. Shubhanshu

    1136 Points

  10. Arnab Bhadra

    1124 Points


24,141 questions
31,143 answers
70,892 comments
29,467 users