0%
0 / 15 answered

Recursive Searching and Sorting Practice Test

15 Questions
Question
1 / 15
Q1

What is the time complexity of this recursive binary search on a sorted integer array of size $n$?


public class Searcher {

    public static int binarySearch(int[] nums, int target, int low, int high) {

        if (low > high) {

            return -1;

        }

        int mid = (low + high) / 2;

        if (nums<u>mid</u> == target) {

            return mid;

        }

        if (target < nums<u>mid</u>) {

            return binarySearch(nums, target, low, mid - 1);

        } else {

            return binarySearch(nums, target, mid + 1, high);

        }

    }

}

Question Navigator