Unformatted text preview: Mock Exam for Midterm I Analysis of Algorithms CS3343 The actual exam will be closed-book and will include true/false and multiple-choice questions. In the actual exam, you will write your answers on the same paper on which the questions are printed. This collection of problems is intended to be representative of the material that is important on the exam. In addition to the problems given here, the problems from in-class practice quizes are also representative of the questions on the exam. 1. If you want to sort an array that you know is already close to being sorted, would it be better to use insertion sort or selection sort? Why? 2. Write an iterative ( i.e. , non-recursive) algorithm that performs binary search on a sorted array. Write a loop invariant that enables you to prove that if the given value is in the array, your algorithm finds it. Prove your loop invariant holds at the start of each iteration....
View Full Document
- Spring '08
- Algorithms, representative, input array, loop invariant holds