Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

State the recursive equation for the worst case running time of this pseudocode: There is no need to actually solve this equation. ****code description find-in-halves

State the recursive equation for the worst case running time of this pseudocode:

image text in transcribed

There is no need to actually solve this equation.

****code description

find-in-halves looks for k in the middle cell mid of the array A[i . . . j]. If k = A[mid], it returns the index, mid, for this cell. Otherwise it compares k with the value of the middle cell, A[mid]. If k is smaller, it makes a recursive call looking for k in the first half of the array A[i..(mid 1)]. If k is larger, make a recursive call looking for k in the second half of the array A[(mid+ 1)..j]. If k is not in A[i . . . j], find-in-halves, it returns 1. The initial call is find-in-halves(A[1 . . . n]).

******code description

function find_in_halves (A[],k,lo=1,hi=n){ mid =(hi+10)/2 if (k==A[ midd ) return mid if (lo ==hi) return 1 else if (k

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions