Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What is the index of the first element accessed in the array when searching f

ID: 3566766 • Letter: 1

Question

1. What is the index of the first element accessed in the array when searching for the number 20?  

Only put in the integer for the index, not the value of the array.

2. What is the index of the second element accessed in the array when searching for the number 20?  

Only put in the integer for the index, not the value of the array.

3. What is the index of the third element accessed in the array when searching for the number 20?  

Only put in the integer for the index, not the value of the array.

4. What is the index of the fourth element accessed in the array when searching for the number 20?  

Only put in the integer for the index, not the value of the array.

5. Will the algorithm access another (the fifth) element in the array when searching for the number 20?  

Only put in the integer for the index, not the value of the array.

0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51

Explanation / Answer

1.

Using Linear Search

The correct answer is 0. The array index starts at 0. So, the first element in the array is accessed at index value 0, while searching the number 20.

Using Binary Search

If the binary search technique is used, then the index of the first element accessed in the array when searching for the number 20 is 8. According to the binary search technique, Hi: = 17, Lo:= 0, Mid:= (17+0)/2 = 8

2.

Using Linear Search

The correct answer is 1. The array index starts at 0. So, the second element in the array is accessed by incrementing the index value by 1. So, the index value becomes 1, while searching the number 20.

Uisng Binary search

If binary search technique is used, then Hi:= 7(8-1), Lo:= 0, Mid: = (7+0)/2 = 3. The index at which second element is accessed is 3.

3.

Using linear Search

The correct answer is 2. The array index starts at 0. So, the third element in the array is accessed by incrementing the index value by 2. So, the index value becomes 3, while searching the number 20.

Using Binary Search

The index at which third element is accessed is 5 because Hi:= 7, Lo: = 4(3+1) Mid : = (7+4)/2 =5

4.

Using Linear Search

The correct answer is 3. The array index starts at 0. So, the fourth element in the array is accessed by incrementing the index value by 3. So, the index value becomes 3, while searching the number 20.

Using Binary Search

The index at which the 4th element is accessed is given by: Hi:= 7, Lo:=6(5+1), Mid : =(7+6)/2 = 6

5.

Using linear Search

The correct answer is 4. The array index starts at 0. So, the fifth element in the array is accessed by incrementing the index value by 4. So, the index value becomes 4, while searching the number 20.

Using Binary Search

The index at which the 5th element is accessed is given by Hi:=7, Lo:=7(6+1), Mid: =(7+7)/2 = 7