We introduce the linear search, binary search, and insertion sort algorithms. Linear search can be used to search for the first occurence of an item in a list. Use binary search when you are searching through a sorted list. Insertion sort is one of several well known algorithms for sorting (and we'll discuss another one next lecture). You can think of these algorithms as demonstrations of the use (and usefulness) of while loops. If you will take the next programming course (CS 2110) later, you will learn much more about the algorithms, different implementations, and analysis.

Do before lecture

The pre-lecture activity is actually the post-lecture activity of Lec 24 on subclassing. Be sure to try it yourself before you read our implementation (to be posted on May 6) now posted with the rest of the Lecture 24 materials.

Lecture materials

Slides: individual slides for viewing, 6-up layout for printing


Lecture Recording

Answers to the question on slide 7 is here.
Read the last three slides (29, 30, 31) on analyzing insertion sort. We will discuss the complexity of the insertion sort algorithm next lecture.