## Question 1 Find the index of the number 60 from the following array using binary search. array = [-10, 11, 60, 70] Also, calculate the number of comparisons required to find the number. ### Options 1. index: 0, steps: 2 Incorrect ---------------------------- 2. index: 1, steps: 1 Incorrect ---------------------------- 3. index: 2, steps: 2 Correct We first calculate the mid element of the array, which is 11. The target element is greater than 11, so we calculate the mid of the right subarray [60, 70]. The mid of this array is 60, which is equal to the target element. So, 60 exists at index 2, and we found it in two comparisons. ---------------------------- 4. index: 2, steps: 3 Incorrect ---------------------------- --------------------------------------------- ## Question 2 Find the index of the number 100 from the following array using binary search. array = [-12, -5, -3, 0, 100] Also, calculate the number of comparisons required to find the number. ### Options 1. index: 0, steps: 2 Incorrect ---------------------------- 2. index: 4, steps: 2 Incorrect ---------------------------- 3. index: 3, steps: 3 Incorrect ---------------------------- 4. index: 4, steps: 3 Correct We first calculate the mid element of the array, which is -3. The target element is greater than -3, so we calculate the mid of the right subarray [0, 100]. The mid of this array is 0, which is less than the target element. Now, we calculate the mid of its right subarray [100], which is 100, equal to the target element. So, 100 exists at index 4, and we found it in three comparisons. ---------------------------- --------------------------------------------- ## Question 3 Find the index of the number 77 from the following array using binary search. array = [-77, 77, 777, 7000] Also, calculate the number of comparisons required to find the number. ### Options 1. index: 1, steps: 1 Correct We first calculate the mid element of the array, which is 77, and the target element is equal to it. So, 77 exists at index 1, and we found it in one comparison. ---------------------------- 2. index: 1, steps: 2 Incorrect ---------------------------- 3. index: 3, steps: 2 Incorrect ---------------------------- 4. index: 7, steps: 2 Incorrect ---------------------------- --------------------------------------------- ## Question 4 Find the index of the number 0 from the following array using binary search. array = [-30, 0, 1, 2, 3,15] Also, calculate the number of comparisons required to find the number. ### Options 1. index: 1, steps: 3 Correct We first calculate the mid element of the array, which is 1. The target element is less than 1, so we calculate the mid of the left subarray [-30, 0]. The mid of this array is -30, which is less than the target element. Now, we calculate the mid of the right subarray [0], which is 0, equal to the target element. So, 0 exists at index 1, and we found it in three comparisons. ---------------------------- 2. index: 2, steps: 0 Incorrect ---------------------------- 3. index: 2, steps: 2 Incorrect ---------------------------- 4. index: 1, steps: 1 Incorrect ---------------------------- ---------------------------------------------