# EECS 183 Lab 1: Algorithms

### Lab accepted for full credit until Tuesday, September 3rd, 11:59 pm Eastern

• The link above is the lab assignment for this week. Be sure to submit the separate google form for attendance, provided by your lab instructor, during the lab to recieve attendance credit.
• The Google lab attendance form is never accepted for assignment credit, and submitting the assignment is never accepted for attendance credit. They are always separate submissions.

In this lab assignment, will write an algorithm to make a sunflower butter and jelly sandwich. While working on the lab, you will learn some of the tools you need to master the course beginning with Project 1.

## Learning Objectives

Students should be able to identify that developing successful algorithms requires them to know the following:

• What data are available to use to solve a problem
• What functions/operations are available
• How to correctly sequence (order) tasks
• How to handle special cases
• How to know the level of detail required

## Key Concepts

• Programs are expressed as a set of instructions.
• The first step in creating a program is creating the set of instructions, expressed as an algorithm.
• Programs must provide a thorough, well-organized, and literal set of instructions, so the algorithm for a program must do the same.

# Assignment

Your task for this lab is to write an algorithm to make a sandwich. You should approach this problem by assuming that your algorithm will be given as a set of instructions to a robot that does not understand what a sandwich is. That is, your algorithm should be taken literally and still be able to produce an edible sandwich.

Complete this lab in a group with 2-3 others. Find a way to write your algorithm somewhere everyone can contribute – whether a piece of paper, a Google Doc, or a laptop everyone can see. You will submit a text copy of your algorithm using the link above.

## How to write an algorithm

An algorithm is a series of steps used to solve a problem. An algorithm can be written in a different language, but it must contain the steps required to solve the problem. You could write an algorithm using English (or any) language prose. However, it is more helpful to write an algorithm using pseudocode or alternately using a flowchart. Pseudocode is an informal description of an algorithm.

Write an algorithm for the problem using the pseudocode from the lecture and lab as a guide. There is no universal pseudocode, and yours may look a little different.

Here is an example of pseudocode for making a sandwich. However, this is nowhere near as detailed as you will need to be.

### Starter Sandwich Algorithm

1. Take a slice of bread.
2. Put sunflower butter on the bread.
3. Put jelly on the bread.
4. Take another slice of bread.
5. Put the second slice of bread on the first.

Here’s a picture of a sandwich made with this algorithm, which will hopefully explain why you need to be more detailed!

If someone in your team has immediate access to the materials, try to execute the steps of the algorithm. Otherwise imagine going through the steps, preferably using other objects to represent the items needed. Be as literal as possible in following the steps of your algorithm – try to make the silliest sandwich that literally follows the instructions. Test each part of your algorithm as you progress: preparing the bread before moving on to sunflower butter, applying sunflower butter before moving on to jelly, etc.