system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5:whats an algorithm?
gpt
An algorithm is basically the recipe, the step-by-step guide, to solving some problem in maths and programming. Algorithms can have names, like "the Quicksort algorithm" or "the Bogosort algorithm", and each one is a series of defined steps to solve a problem. A problem can have lots of different algorithms that reach a valid solution in different ways with different tradeoffs (eg one algorithm might use a lot of memory, one algorithm might be very slow).

Here are two examples.

# Problem: sort a list of numbers so that [3, 2, 5, 1, 8] becomes [1, 2, 3, 5, 8]

## Bubble sort algorithm

1. Compare the first item (A) and the second item (B) in the list.
2. If A < B, they are in the right order, so move onto comparing the second item and third item in the list.
3. If A > B, they are in the wrong order, so swap them.
4. When we get to the end of the list, go back to the beginning and do the same thing again.
5. If we get all the way from the beginning to the end never having to swap anything, that means everything is in the right order, and we're done.

## Bozosort algorithm

1. Check if the list is in order.
2. If it is, we're done.
3. If it's not, swap two random items.
4. Repeat.