[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Outlines] [Labs] [Assignments] [Quizzes] [Questions] [Exams] [Examples]
Back to The Parts of an Algorithm. On to Sorting.
Held Monday, February 7, 2000
Overview
Today we consider ways in which one might choose between different algorithms that purport to solve the same problem. We look at a mathematical notation, Big O, that lets us describe the space or time requirements of an algorithm.
Question 9 for today: Suppose you've been given two sets of instructions that solve the same problem. What criteria might you use to determine whether one is better than the other?
Question 10 for Tuesday: Describe how to put a pile of books in alphabetical order by author.
Notes
Contents
Summary
1. Put the list in order 2. Return the first element
1. Set guess to the first element of the list
2. For each element, e, of the list
a. if (e < guess) then
i. guess = e.
3. Return guess
1. Set guess to the last element of the list
2. For each element, e, of the list
a. if (e < guess) then
i. guess = e.
3. Return guess
1. Return the last element of the list
1. For each number, make a pile of Lego (tm) pieces stacked
on top of each other.
2. Put a board higher than all of the piles and move it down.
a. Whenever it hits a pile, remove that pile
b. Stop when one pile is left
3. The number of Lego (tm) pieces is the smallest grade
1. If there is only one grade in the list,
a. Return that element
Otherwise
b. Split the list into two equal halves
c. Find x, the smallest grade in the first half
d. Find y, the smallest grade in the second half
e. Return the smaller of x and y
guess many times; in others, we won't update
it much.
Saturday, 22 January 2000
Monday, 7 February 2000
Back to The Parts of an Algorithm. On to Sorting.
[Instructions] [Search] [Current] [News] [Syllabus] [Glance] [Links] [Handouts] [Outlines] [Labs] [Assignments] [Quizzes] [Questions] [Exams] [Examples]
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/CS105/2000S/Outlines/outline.09.html
Source text last modified Mon Feb 7 09:30:25 2000.
This page generated on Mon Feb 7 09:29:51 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at rebelsky@grinnell.edu