Question DSA-SRCH-0047
MediumWhy is mid = lo + (hi − lo) / 2 preferred over (lo + hi) / 2 in Java or C?
- A.
It works on unsorted arrays
- B.
lo + hi can overflow for large indexes
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Searching and Binary Search question
Why is mid = lo + (hi − lo) / 2 preferred over (lo + hi) / 2 in Java or C?
It works on unsorted arrays
lo + hi can overflow for large indexes
Sign up free to see the answer and a step-by-step explanation.
It gives a different answer
It is faster