CS21 Week7 In-Class Exercises
- Save a copy of the program that performs linear search to your
own directory. Compile it and run it. Make sure you understand how
it works.
- Save a copy of the program that performs binary search to your
own directory. Compile it and run it. In order to help you
understand how it works, add a printf statement inside the
for loop just after the assignment statement for
mid. Print out the values of low, mid, and
high. Watch how they change as the search proceeds. Which
locations in the array will require binary search to perform the most
steps?
- Because the binary search algorithm depends on the array being
sorted, it is worthwhile to check whether the array really is in the
proper order. Complete the function IntegerArrayIsSorted
that is started at the end of the file and is called as the first
statement in the main program.
- Show me your updated version of the binary search program.
- Go read through the homework assignment for this week.