Discussion
Consider a program that reads 500 integers in the range of [0, 100] that represents the score of 500 students. Frequency of each score above 50 is then printed. For the program to store the frequencies the best way is
Answer: D
The best way is an array of 50 numbers.
Only the frequencies of scores above 50 are printed, and the possible scores above 50 in the range [0, 100] are 51, 52, ..., 100: exactly 50 values. One counter for each, indexed by score minus 51, needs an array of 50 numbers.
An array of 100 numbers wastes space on scores that are never reported, an array of 500 confuses the number of students with the number of possible scores, and a dynamic array of 550 has no basis at all.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development