Question:
What is the worst-case number of comparisons required by Binary Search in a sorted array of \(n\) elements?
\(n\) तत्वों के एक सॉर्ट किए गए ऐरे में बाइनरी सर्च द्वारा आवश्यक तुलनाओं की अधिकतम (वर्स्ट-केस) संख्या क्या है?
Options:
- \(\lfloor \log_2 n \rfloor + 1\)
- \(n\)
- \(n/2\)
- \(\log_2(n) – 1\)
- \(\lfloor \log_2 n \rfloor + 1\)
- \(n\)
- \(n/2\)
- \(\log_2(n) – 1\)
Correct Answer: a)
Explanation:
In Binary Search, each comparison divides the search space in half. The maximum height of the decision tree is \(\lfloor \log_2 n \rfloor + 1\), giving the worst-case number of comparisons (Option a).
बाइनरी सर्च में अधिकतम तुलनाओं की संख्या \(\lfloor \log_2 n \rfloor + 1\) होती है (विकल्प a)।