Problem Solving and Computing (CSC-103 98S)

[Instructions] [Search] [Current] [Changes] [Syllabus] [Handouts] [Outlines] [Journal] [Problems] [Computing] [SamR Docs] [Tutorial] [API]

Computing Problems 2: Basic Algorithms

Assigned: Thursday, January 22, 1998
Due: Tuesday, January 27, 1998

Summary. In this assignment, you will be trying to develop and write up a variety of algorithms.

Intent. This assignment is intended to give you more experience thinking about, writing up, and applying algorithms.

Note. Some of these are fairly difficult problems. Work hard on them, but don't be disappointed if you can't get a "perfect" answer (or even a correct answer).

0. Making Sandwiches

Come up with an unambiguous set of instructions I could follow to make a peanut butter and jelly sandwich from the ingredients at the front of the room. You should assume that I'm fairly clueless and will misinterpret our instructions if at all possible.

1. Building Permutations

One step of the shortest tour algorithm calls for finding "all permutations of the cities". Suppose we were only dealing with four cities: Boston, New York, Des Moines, and Chicago. What are the permutations of those four cities?

2. Counting Permutations

Since we're going to have to look at all the permutations, it might help to be able to count them. If we have to find all permutations of 6 cities, how many are there? 7 cities? 10 cities? Is there a general formula? What if we know which city we're starting with?

3. Instructions for Building Permutations

If we are going to use permutations, we must build permutations. Give a set of instructions that "anyone" could follow that describe how to build all the permutations of a list of cities.

4. Guessing Words

I have a list of N words in alphabetical order. You want to determine where in the list a particular word falls (or if it is in the list at all). You can find out what word is at any position.

For example, the list may be "Alpha,Beta,Delta,Epsilon,Gamma" (although you don't know that) and it's your goal to find out whether "Fly" is in the list. You might ask what is at position 1 ("Alpha"), position 2 ("Beta"), position 3 ("Delta"), position 4 ("Epsilon"), and position 5 ("Gamma"). Since you didn't find it at any of the five positions, you know that it's not in the list.

You might also have asked what is at position 4 ("Epsilon") and position 5 ("Gamma"). Since you know that "Fly" must fall between "Epsilon" and "Gamma" and there is nothing between position 4 and position 5, you know "Fly" is not in the list.

Suggest a strategy you might use to figure out where (or if) a word appears in the list, given that all you are able to do is find out what word is at what position. Does your answer change if you need to find the answer as quickly as possible?

If you'd like to try out your strategy, I've set up a simple version of this game that you can get by typing
% /home/rebelsky/bin/guess (don't type the percent sign, and hit a carriage return).

If you'd like to make sure that you play exactly the same game, type
% /home/rebelsky/bin/guess NNN where the NNN is an integer.

5. Four fours

One solution to the four fours problems is a brute force approach: try all combinations of four fours. See if you can write up an algorithm that describes this approach in more detail. This is a particularly difficult problem, so don't worry if you can't do it.

[Instructions] [Search] [Current] [Changes] [Syllabus] [Handouts] [Outlines] [Journal] [Problems] [Computing] [SamR Docs] [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.

Source text last modified Thu Jan 22 09:34:35 1998.

This page generated on Thu Apr 2 13:49:51 1998 by SiteWeaver.

Contact our webmaster at