logo

Crowdly

Browser

Add to Chrome

Antud on sorteeritud massiiv A: binary_search(array, key)     n = leng...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Antud on sorteeritud massiiv A:

indeks0123456789101112131415
A[indeks]8111324284749535458596971758388

binary_search(array, key)

   n = length of array

   low = 0

   high = n - 1

   mid = (low + high) / 2

   while (array[mid] doesn't match key)

       if (array[mid]key)

           high = mid - 1

       else

           low = mid + 1

       if (lowhigh)

           return no match

       mid = (low + high) / 2

   return array[mid]

Milliseid arve vaatab kahendotsing läbi 13 otsimiseks (kaasa arvatud otsitav element)? Eraldage arvud tühikutega.
More questions like this

Want instant access to all verified answers on moodle.taltech.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome