GATE CSE
First time here? Checkout the FAQ!
x
0 votes
49 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.3k points)   | 49 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.3k points)  

Related questions

0 votes
0 answers
1
asked in DS by srestha Veteran (52.3k points)   | 71 views
+1 vote
0 answers
3
asked in DS by Akriti sood Veteran (12.3k points)   | 39 views


Top Users Mar 2017
  1. rude

    4008 Points

  2. sh!va

    2984 Points

  3. Rahul Jain25

    2804 Points

  4. Kapil

    2604 Points

  5. Debashish Deka

    2050 Points

  6. 2018

    1406 Points

  7. Vignesh Sekar

    1292 Points

  8. Bikram

    1204 Points

  9. Akriti sood

    1162 Points

  10. Sanjay Sharma

    964 Points

Monthly Topper: Rs. 500 gift card

21,435 questions
26,746 answers
60,901 comments
22,916 users