Discussion
_________ comparisons are necessary in the worst case to find both the maximum and minimum of n numbers.
Answer: C
The number of comparisons needed in the worst case to find both the maximum and the minimum of n numbers is about \(\lceil 3n/2 \rceil - 2\), and option C is the closest listed form. Pair the elements, compare each pair (n/2 comparisons), then find the maximum among the winners and the minimum among the losers (about n/2 - 1 each).
\(2n - 2\) is what the naive method needs, \(n + \lfloor \lg n \rfloor - 2\) is the bound for finding the two largest elements, and \(2 \lg n - 2\) is too small to be possible.
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