
Donald W. answered 07/30/22
Experienced and Patient Tutor for Math and Computer Science
The recurrent equation should be something like this:
R(n) = { 1 when n <= 2, 1 + 2*R(n/2) when n > 2 }
Can you solve this equation yourself?
Himanshu S.
asked 07/27/22Function maximum(x,y)
{ return maximum in A[x..y]}
1. if y - x £ 1 then return (max(A[x],A[y]))
2. else
3. max1 <--- maximum(x, [(x + y) / 2] )
4. max2 <--- maximum( [(x + y) / 2] + 1 , y)
5. return(max(max1, max2)
Give a recurrence equation for the worst-case number of comparisons used by maximum (1, n), and solve this recurrence equation, (you may assume that n is a power of 2)
Donald W. answered 07/30/22
Experienced and Patient Tutor for Math and Computer Science
The recurrent equation should be something like this:
R(n) = { 1 when n <= 2, 1 + 2*R(n/2) when n > 2 }
Can you solve this equation yourself?
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.