Week1Mock1MCQ40

Run Settings
LanguageJava
Language Version
Run Command
// import java.util.*; public class Main { public static int search(int[] a, int first, int last, int sought) { int mid = (first + last) / 2; // if (<missing code>) { if (a[mid] > sought) { last = mid - 1; return search (a, first, last, sought); } // else if (<missing code>) { else if (a[mid] < sought) { first = mid + 1; return search(a, first, last, sought); } return mid; } public static void main(String[] args) { // Harbor, Week 1, Mock 1, PR_PracticeTest_1.pdf // AP CS A // MCQ 40 // A sorted array of integers int[] arr = {2, 3, 5, 7, 11, 13, 17, 19}; int number = 13; System.out.println("Target at index number: " + search(arr, 0, arr.length-1, number)); } }
Editor Settings
Theme
Key bindings
Full width
Lines