Skip to content
Algorithms for Beginners

Words, explained simply

Coding is full of jargon. Here is every word this site uses, in plain English. They start with the basics and get more advanced as you go down.

Code
Instructions for a computer, written in a language it understands. Like a recipe, but the cook follows it exactly, word for word.
JavaScript
The programming language this site uses. It runs in every web browser, so you can try it right here with nothing to install.
Variable
A labelled box that holds a value. You give it a name, put something in it, and use the name later to get it back.
Example:let age = 30;
String
A piece of text, written between quotes. Each letter in it is a character.
Example:"hello"
Boolean (true or false)
A value that can only be true or false. Like a light switch: on or off.
Example:let isOpen = true;
Array (list)
A list of values kept in order, inside square brackets. Like a row of numbered lockers.
Example:const prices = [3, 8, 5];
Index (position)
Where an item sits in a list. Counting starts at 0, not 1, so the first item is at position 0.
Example:prices[0] is the first price
Length
How many items a list (or letters a string) has. The last position is always length - 1.
Example:[3, 8, 5].length is 3
If (a decision)
Runs some code only when something is true. Like: if it's raining, take an umbrella.
Example:if (age >= 18) { ... }
Loop
Code that repeats. A for loop repeats once per item or a set number of times; a while loop repeats as long as something stays true.
Example:for (let i = 0; i < 3; i++) { ... }
Nested loop
A loop inside another loop. For each item, the inner loop goes through everything again, which gets slow fast.
Function
A named, reusable recipe. You give it ingredients (inputs), it does its steps, and hands back a result.
Example:function double(n) { return n * 2; }
Parameter (input)
A name for an ingredient a function receives. In double(n), n is the parameter; when you call double(5), it holds 5.
Return
How a function hands back its answer. As soon as return runs, the function stops.
Example:return total;
console.log
Prints something so you can see it. The easiest way to find out what your code is really doing.
Example:console.log("hi");
Object
A bundle of named values, in curly braces. Like a form with labelled boxes.
Example:{ name: "Ana", age: 31 }
Map
A lookup table: it stores pairs of a key and a value, and finds any key instantly. Like a coat check: hand over a ticket, get your coat straight back.
Example:seen.set(8, 1); seen.get(8);
Set
A collection that only remembers which things it has seen, with no repeats. Like a guest list: a name is either on it or not.
Example:seen.add(7); seen.has(7);
Key
The label you look something up by in a Map or object, like a word in a dictionary.
Hash, hashing
A quick calculation that turns a key into a shelf number, so a Map can jump straight to it instead of searching.
Algorithm
A step-by-step method for solving a problem. A recipe is an algorithm for a cake.
Pattern
A trick that solves a whole family of problems. Learn the trick once, and you can solve problems you've never seen.
Template
The usual shape of a pattern's code. You fill in the parts that change for each problem.
Brute force (the slow way)
Trying every possibility, one by one. It's usually easy to write and correct, but slow on big inputs.
Big O
A way to say how much slower code gets as the input grows. It's about the trend, not exact seconds.
O(1): constant time
Takes the same time no matter how big the input is. Like opening a book at page 1.
O(log n): logarithmic time
The work grows very slowly, because each step throws away half. A million items need only about 20 steps.
O(n): linear time
The work grows in step with the input: twice the items, twice the work. One pass.
O(n²): quadratic time
Twice the items means four times the work. Usually a loop inside a loop. Fine for 100 items, painful for 100,000.
Pointer
A variable that holds a position in a list, like a finger resting on one item. left and right are pointers.
Sorted
In order, smallest to biggest (or A to Z). Many fast tricks only work on sorted lists.
In place
Changing the list you were given, instead of making a new one. Saves memory.
Window
A stretch of items next to each other in a list, from a left position to a right one.
Stack
A pile where you only touch the top: add with push, take with pop. The last thing in is the first out, like a pile of plates.
Recursion
A function that calls itself on a smaller version of the problem, until the problem is small enough to answer directly.
Edge case
An unusual input that can break code: an empty list, one item, all the same, very big numbers.
Test
An example input with the answer it should give. Your code passes if it gives that answer.
Bug, debugging
A bug is a mistake in code. Debugging is finding it, often by printing values with console.log.
Syntax error
The code isn't written correctly, like a missing bracket, so the computer can't even start running it.
Spaced repetition
Reviewing something just before you'd forget it: after a day, then a few days, then a week. The fastest way to remember for good.