Question
Download Solution PDFThe recurrence relation for binary search algorithm is :
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFThe correct answer is T(n) = T(n/2) O (1).
Key Points
- The binary search algorithm is a search algorithm that finds the position of a target value within a sorted array.
- Binary search works by repeatedly dividing the search interval in half.
- If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half.
- Otherwise, narrow it to the upper half. Repeat until the value is found or the interval is empty.
Additional Information
- The recurrence relation for the binary search algorithm is T(n) = T(n/2) + O(1).
- This is because at each step, the algorithm divides the problem size by 2 (hence T(n/2)) and performs a constant amount of work (O(1)).
- The time complexity of binary search is O(log n) in the worst case.
- Binary search is more efficient than linear search, especially for large datasets.
Last updated on Feb 20, 2025
-> A total number of 113 revised vacancies have been announced for the post of Scientific Assistant in Computer Science (CS), Information Technology (IT), and Electronics & Communication (EC) streams.
-> Online application form, last date has been extended up to from 17th April 2025.
->The NIELT has revised the Essential Qualifications for the post of Scientific Assistant. Candidates must possess (M.Sc.)/ (MS)/ (MCA) / (B.E.)/ (B.Tech) in relevant disciplines.
-> The NIELIT Scientific Assistant 2025 Notification has been released by the National Institute of Electronics and Information Technology (NIELIT).