Algorithms

What is an Algorithm?

Examples

Bake a Cake

Determine if Number is Even or Odd

Find the Largest Number in a Set

Structured Programming

Structured programming forms the basis of all modern programming languages, and can be used to implement algorithms.

The three basic control structures are:

Sequence

Selection

Iteration

Where do we see these structures in the algorithms above?

Applications and Domains

Thinking algorithmically:

While human brains are often compared to computers, they are actually quite different. In order to understand how computers work, we need to think in "instructions", or discrete steps.

As we move through the applications below, let's think about the "humanlike" and "computerlike" ways of solving problems.

Sorting

"How do we arrange a set of items in a specific order?"

Searching

"How do we find a specific piece of information?"

Encryption

"How do we encode/decode information to and from human readable?"

Compression

"How do we represent the same information with fewer bits?"

Pathfinding

"How do we find the optimal path between two points?"

Flocking

"How do we simulate flock behavior?"

Network Analysis / Search Ranking

Classification

"How do we categorize items from a set of data?"

Prediction

"How do we predict a future value based on a set of data?"

Reinforcement Learning

"How do we get a computer to learn on its own?"

Critical Thinking Exercise

Problem: We need to fly from Indianapolis to Los Angeles.

The following cities are possible stops:

Draw a graph of the possible routes between these cities.

Consider: