Discussion
Which of the following is true about the time complexity of the Binary Search algorithm ?
Answer: B
Binary search runs in O(logn) time.
Each comparison halves the part of the sorted array still to be searched, so after k steps \(n/2^k\) elements remain, and the search ends after about \(\log_2 n\) steps.
O(n) is linear search, O(n log n) is efficient sorting, and \(O(n^2)\) is simple sorting such as bubble sort.
For example, a sorted array of a million elements needs at most about 20 comparisons.
No comment is present. Be the first to comment.
Loading…
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