**Overview**:

Some of the most important algorithms used in computing are
in the category "search and sort." These are useful in a variety of
settings, such as web search, alphabetic sorting of a list of names,
etc. They are also related, since the most efficient search
algorithms occur on lists that are sorted. This lab provides an
opportunity to explore the functioning of search and sort algorithms,
as well as their efficiency. The readings and problems for this
assignment are in Chapter 3 of your text.

The buttons

For example, select

Now opn the

These animators will be useful for answering some of the questions below.

**Problem 1** Write an algorithm that reads a number
`n` and a list of `n-1` distinct integers from the
user in the range `1,2,...,n` and figures out what is the
missing number. For instance, if the user types in

6 1 5 3 2 6your algorithm should print

The missing number is 4

Analyze the worst-case and best-case running time of your algorithm.

**Problem 2** Write an algorithm that reads a number
`n` and a list of `n` numbers from a user and computes
and prints the median element(s) in the list (the median is an element
which has an equal number of elements smaller and larger than it).
For instance for the list

4 3 1 2 5 7 6the median is 4. For the list

5 4 3 8 6 7 1 2the medians are 4 and 5.

You can use any of the algorithms studied in class as a black box, without writing the code for them. Analyze the worst-case and best-case running time of your algorithm.

**Problem 3** Write an algorithm that evaluates a
polynomial at a point. The algorithm should read in from the user a
list of `n+1` coefficients, `a _{0}, a_{1}, a_{2},...,a_{n}` and a
value

Analyze the worst-case and best-case running time of your algorithm.

- The Designing Algorithms section.

Be sure to justify your answers! You may do this work either with a word processor or by hand. If you type your solutions, bring a hard copy of your assignment and hand it in class. If you write by hand, do your best at writing legibly and leave space between problems.

You may choose to do this assignment either by yourself or in a group. However, solutions should be written up individually and handed in on Tuesday, at the beginning of class.

*Once you are finished in the lab, if you saved any
documents in yout collaboration personal directory, be sure to drag
the
csci107 icon to the Trash (this step disconnects you
from the server and prevents someone else, who may use this iMac later
in the day, from accidentally accessing files in your personal folder)
and log out!
*