[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]

Back to Recursion. On to Recursion, Revisited.

**Held** Monday, February 22

**Summary**

- Laboratory: A2: Searching

**Contents**

**Notes**

- Exam 1
- I've corrected some typos on the exam. There's no guarantee of extra credit for identifying typos, but you certainly get some good will.
- There have been some questions on how to test your inventory class from problem 5. We'll spend some time discussing that problem.
- Are there other questions.

- As you may have noted, a new whiteboard has arrived. Later this week, I'll show you how cool it is.
- Today at noon, there is a meeting in 2413 to discuss summer research opportunities in computer science at Grinnell. There are also web pages describing
- On Tuesday at 12:15 in 2413, there is an informational meeting on an MBA Program with specialization in information and software systems. It seems that students will receive a $20,000 fellowship plus tuition.
- On Tuesday at 4:??, there is a meeting to discuss summer research opportunities in mathematics at Grinnell.
- A slight change in the schedule: today we'll work on lab A2, after
a short discussion of searching.
- Sorry if today's notes are therefore more abbreviated. You should have read about binary search in the lab manual, and you'll get to read about it again in the next reading from the book.

- A technique for searching through sorted arrays.
- One of the classic algorithms.
- Takes advantage of the strategy of
*divide and conquer*: you break the list in half, and only work on one half. - Elegantly expressed recursively.
- (Can also be expressed iteratively.)
- To search for element
*e*in sorted array*A*, search for*e*in the subrange of*A*from 0 to (last index in A). - To search for element
*e*in subrange*l*to*u*of*A*,- Identify a midpoint,
*m* - If
*e*is at the midpoint, return the appropriate information. - If
*e*is smaller than the value at the midpoint, throw away the upper half of the array (reduce the subrange). - If
*e*is greater than the value at the midpoint, throw away the lower half of the array (reduce the subrange).

- Identify a midpoint,
- We'll do an example that has to do with phone books.
- What's the running time?
- How might we code it in Java?

Do A2.5. We'll discuss step 1 aloud.

**History**

- Created Monday, January 11, 1999.
- Added short summary on Friday, January 22, 1999.
- Filled in details on Monday, February 22, 1999.

Back to Recursion. On to Recursion, Revisited.

[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]

**Disclaimer** Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/99S/Outlines/outline.17.html

Source text last modified Mon Feb 22 10:52:51 1999.

This page generated on Fri Mar 12 13:12:11 1999 by SiteWeaver. Validate this page's HTML.

Contact our webmaster at rebelsky@math.grin.edu