Draw Recursion Tree Binarysearch Called Array 1 3 7 8 10 13 20 22 Searching Key K 2 Node T Q37104626

Draw recursion tree for BinarySearch called on an array [1, 3,7, 8, 10, 13, 20, 22], and searching for key K = 2. At each node ofthe tree, record the values of i, j. For example, initial node willhave 1..8 recorded on it.

6 function BinarySearch(Al], i, j, K) if (i>j) then return -1 2 4 5 if (K = A[midp) then 6 | index ← midp 7 s else if (K< Alm

6 function BinarySearch(Al], i, j, K) if (i>j) then return -1 2 4 5 if (K = A[midp) then 6 | index ← midp 7

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.