Questions
Questions
Single choice

Recr_4 Identify the recurrence relation for the binary_search function described below, which recursively searches for a value in a sorted list.

Options
A.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\2T\left(n-1\right) + \Theta(1) & \text{otherwise}\end{cases}
B.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(n-1\right) + \Theta(n) & \text{otherwise}\end{cases}
C.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\2T\left(\frac{n}{2}\right) + \Theta(1) & \text{otherwise}\end{cases}
D.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(\frac{n}{2}\right) + \Theta(1) & \text{otherwise}\end{cases}
E.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(\frac{n}{2}\right) + \Theta(n) & \text{otherwise}\end{cases}
F.T(n) = \begin{cases} \Theta(1) & \text{if } n <2 \\T\left(n-1\right) + \Theta(1) & \text{otherwise}\end{cases}
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
To begin, restate what is being asked: identify the recurrence relation for a binary_search function that recursively searches a sorted list. Option 1 evaluates the cost as 2T(n-1) + Θ(1). This would correspond to two recursive calls on size n-1, which is not how binary search operates; binary search halves the problem size, not processes two nearly full-sized subproblems. Therefore this option mischaracterizes the branching factor. Option 2 proposes T(n-1) + Θ(n). Here the non-recursive ......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

Similar Questions

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!