Skip to content
BENIBIX Learn

Algorithms & Data Structures

The core problem-solving toolkit of code · 39 terms

Sort
Compare

Algorithm Basics

5

What an algorithm is, and how its cost is measured as data grows.

A set of clear steps that solves a problem. Programs are built from them.

How fast an algorithm's work grows when its input grows.

How much more work as the input grows. It is written in Big O.

How much extra memory a task needs. It grows with the input.

How fast code runs on the best input, the worst one and a normal one.

Data Structures

14

Ways to arrange data in memory, each fast at different jobs.

A way to arrange data so a program can use it well.

A store of keys and values. It finds a value by its key in one step.

Two keys that land in the same slot of a hash table.

Linear Structures

4

Structures that keep items in a line, one after another.

A chain of items. Each one holds a value and points to the next.

A pile where the last item in is the first one out. You push and pop.

A line where the first item in is the first one out. Join at the back.

An array that grows. When it is full, it moves to a bigger block.

Non-Linear Structures

7

Trees and graphs, where items branch out or link in many ways.

Nodes joined in a branching shape, with one root at the top and no loops.

A tree where each node has at most two children, a left and a right.

A binary tree kept in order. Small values go left; big ones go right.

A tree that keeps the smallest item on top, or the largest.

A tree that stores words letter by letter. Shared starts share a branch.

Nodes joined by edges, where any node can link to any other.

A graph of one-way arrows with no loops. It shows what must come first.

Search Algorithms

5

Ways to find an item in a list, or a path through a graph.

Checking each item in turn until you find a match.

Finding an item in a sorted list. Each step cuts the search in half.

Walking a graph one layer at a time, nearest nodes first.

Walking a graph down one path as far as it goes, then backing up.

A way to find the shortest route through a graph where each road has a length.

Sorting Algorithms

7

Ways to put a list in order, and what each one costs.

Steps that put a list in order, like small to big or A to Z.

A simple sort that swaps neighbours until the list is in order. It is slow.

Take each item in turn. Slide it back to its right place.

Find the smallest item left. Move it to the front. Do it again and again.

A sort that splits the list in halves, sorts them, then merges them back.

A fast sort. It splits items around a pivot, then sorts each side.

The sort Python uses. It finds runs already in order and merges them.

Algorithm Design Techniques

8

General plans for designing an algorithm for a new problem.

You try each possible answer in turn. You stop when one works.

Cutting a big problem into small ones like it. Solve each, then join the answers.

The simple case where a function that calls itself stops.

Try a choice, and step back to try another when it leads to a dead end.

Taking the choice that looks best at each step. It never goes back.

Saving the answers to small parts that repeat. Each is solved once.

Saving a function's answer for each input. The same call is then instant.

Walking a list with two markers at once. Often one starts at each end.