The purpose of this module is to explore computational thinking and logical problem solving. We will learn how to break problems down into step-by-step solutions called algorithms.
We will then look at visually diagramming algorithms using a system called Activity Diagrams.
Prerequisite Modules:
Much of the content in this module was condense from these Virginia Tech Algorithm notes. The embedded Flash demos were taken directly from these notes.
If you find the topics in this module fascinating you may wish to read these notes in full.
Upon completion of this module, you should be able to:
Imagine your journey to school today written out as a list of directions:
This set of instructions solves a particular problem: Navigating from your home to the RRC campus.
Your instructor needs a new pair of shoes.
Write out a step-by-step algorithm your instructor can follow to acquire new shoes.
Your algorithm should be as detailed as possible, describing not only the journey to the shoe-store but also the shoe selection and purchase process.
An algorithm is a set of instructions for solving a problem.
In other words, an algorithm is a way of capturing intelligence and sharing it with others.
A recipe is another example of an algorithm. One does not need to be an expert cook to create a meal by following a well-designed recipe.
Might a recipe written for a novice look different than one written for an experienced cook?
Consider a single-player game with a playing board consists of 7 squares in a row.
The aim is swap the positions of the orange and blue pieces.
Setup
To begin, orange pieces are placed in the three leftmost squares. Blue pieces are placed in the three rightmost squares.
Game Play
Pieces can move either by sliding into an adjacent empty square, or by jumping a single adjacent piece into the empty square beyond.
Your goal is to write down step-by-step instructions for winning this game.
Your instructions should be clear enough so that someone who has never played this game can follow them without asking you any questions.
How many steps does you winning algorithm include? Can you create a version of it that only uses 15 instructions?
Sorting is a common problem handled by computers.
Consider how most webmail applications allow us to sort our email messages in several ways: date received, subject, sender, etc. Each time you reorder your email, your computer uses a sorting algorithm to sort them.
Since computers can compare a large number of items quickly, they can sort large collections at incredible speeds.
Do this a few times, each time starting with a randomized list.
How many comparisons do you need to make to sort the list each time?
For any given problem, it is possible that there is more than one algorithm that represents a correct solution.
Two important considerations for judging the efficiency an algorithm are:
Let’s investigate the time efficiency of a number of popular sorting algorithms:
It is often useful to draw out a algorithm is such as way as to visualize the required processes and decisions. The above flow-chart describes an algorithm for making friends.
In the BIT program you will make use of Activity Diagrams (a form of flow chart) when designing your programs.
For your reference, here are the BIT Activity Diagram notes:
Video:
In this module we learned how to break a problem down into a step-by-step algorithm.
We’re now ready to bring these concepts to your work with the Scratch programming language. Programming is the art of turning algorithms into instructions that a computer can follow.