Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Algorithms (AP)

Scott Kowalczewski edited this page Sep 5, 2019 · 20 revisions

An algorithm is a set of instructions used to solve a problem. You use algorithms every day, for example:

Getting Ready for School
1. Wake Up
2. Eat Breakfast
3. Brush Teeth
4. Get Dressed
etc

Algorithms can be expressed in plain language (like above), flow charts (later!) or pseudocode (code intended to be read by humans and not computers).

There are three main components of algorithms:

Sequencing

This refers to the fact that the steps need to be completed in that order (top to bottom). It wouldn't make sense to Brush Teeth before Wake Up.

Selection

Perhaps something should only happen IF a condition is met. For example:

Getting Ready for School

1. Wake Up
2. I am hungry:
     Eat Breakfast
3. Otherwise:
     Eat Breakfast at school

Iteration

Certain steps can be repeated a certain number of times, or until a certain condition is met.

Eating a Sandwich
1. Open mouth
2. Insert sandwich in mouth
3. Bite
4. Chew
5. Repeat all steps until sandwich is done

Not all algorithms are the same, even if they are accomplishing the same task.  Some may be more _efficient_ than others.

In class you will be given a problem to solve in groups using an algorithm.  Then we will discuss which one is the most efficient and why.

Clone this wiki locally