
532 CHAPTER 8 Single-Dimensional Arrays
The element at index 6 (22) is smaller than 34, so we search in the right
subarray. The value of middle is now 7.
At this point, start, end, and middle all have the value 7. The element at
index 7 (36) is larger than 34, so we assign end the value middle – 1, which
is 6. This makes end less than start and consequently makes the while loop
condition evaluate to false. We have not found 34, so we return 1.
8.7 Programming Activity 2:Searching and Sorting Arrays
In this activity, you will work again with a 15-element integer array, per-
forming these activities:
1. Write a method to perform a Sequential Search of ...