Algorithms

Tom Kelliher, CS 102

Nov. 29, 2006

Administrivia

Announcements

Written quiz Friday.

Assignment

No reading, no online quiz.

From Last Time

JavaScript lab.

Outline

  1. Introduction.

  2. Lab.

Coming Up

Artificial Intelligence.

Introduction

An algorithm is a set of simple steps for accomplishing something. For example, a computation.

Here is an example for determining if any number in a list is negative.

I am going to give you a series of numbers, one at at time. When I am finished, I will say ``End.'' If any of the numbers is negative, you should say, ``Yes, halt.'' If I say ``End,'' you should reply, ``No, halt.''
This algorithm will work for any finite list of numbers.

Lab

Working as a class, solve the following problems.

  1. Form the sum of a list of numbers.

  2. Find the smallest item in a list of numbers.

  3. Determine the average of a list of numbers.

  4. Determine if a list of numbers is sorted in ascending order. (Assume all items are unique.)

  5. Determine if a list of numbers has size exactly five.

  6. Determine if a list of numbers contains a specified number (provided first).

  7. Sort a list of numbers into ascending order. (Assume all items are unique.)

  8. Determine the median of a list of numbers.

  9. Determine the most frequently occurring score (the mode) on an exam worth 100 points.



Thomas P. Kelliher 2006-11-27
Tom Kelliher