Algorithms

Tom Kelliher, CS 102

Apr. 24, 2006

Administrivia

Announcements

Written quiz Friday. Refer to readings on class Web site. Will answer questions Wednesday.

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. Example list:

12 45 3 -9 16 5
put your left finger on the first number
put your right finger on the second number
move your right finger one place to the right

while your left finger is to the left of your right finger

   if the number pointed to by your left finger is negative

      say "Yes"
      stop

   move your left finger one place to the right

say "No"
stop
Note that this will work for a list of any size -- your algorithms should, too.

Lab

Working in groups of two, the ``leader'' will teach the ``computer'' to solve the following problems, without saying what the problem is:

  1. Form the sum of a list of numbers.

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

As a class, design a sorting algorithm.



Thomas P. Kelliher 2006-04-24
Tom Kelliher