401 views
0 votes
0 votes

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

1 Answer

2 votes
2 votes
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.

Related questions

0 votes
0 votes
1 answer
2
sandeep singh gaur asked Feb 18, 2019
1,177 views
A Sorted array of n elements contains 0 and 1 to find out majority of 0 and 1.How much time it will take???and please explain Meaning -majority of 0 and 1??
0 votes
0 votes
1 answer
3
SKR1997 asked Feb 17, 2019
877 views
Find the address of the position [10, 11, 12] of array A in column major order? Given Dimension is A[1:10, -5:15, -10:15], w is two word count, and Base address is 200.
0 votes
0 votes
0 answers
4