CrashCourse · @crashcourse
Intro to Algorithms: Crash Course Computer Science #13
Uploaded June 8, 2017 · Length 11:44
Summary
Learn about algorithms, how they work, and compare selection sort and merge sort's efficiency using Big O notation.
- introduction to algorithms
- selection sort explained
- merge sort explained
- algorithm complexity
- big O notation
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:03
Hi, I’m Carrie Anne, and welcome to CrashCourse Computer Science!
- 0:05
Over the past two episodes, we got our first taste of programming in a high-level language,
- 0:10
like Python or Java.
- 0:11
We talked about different types of programming language statements – like assignments,
- 0:14
ifs, and loops – as well as putting statements into functions that perform a computation,
- 0:18
like calculating an exponent.
- 0:20
Importantly, the function we wrote to calculate exponents is only one possible solution.
- 0:24
There are other ways to write this function – using different statements in different
- 0:27
orders – that achieve exactly the same numerical result.
- 0:30
The difference between them is the algorithm, that is the specific steps used to complete
- 0:34
the computation.
- 0:35
Some algorithms are better than others even if they produce equal results.
- 0:38
Generally, the fewer steps it takes to compute, the better it is, though sometimes we care
- 0:42
about other factors, like how much memory it uses.
- 0:45
The term algorithm comes from Persian polymath Muḥammad ibn Mūsā al-Khwārizmī who was
- 0:49
one of the fathers of algebra more than a millennium ago.
- 0:52
The crafting of efficient algorithms – a problem that existed long before modern computers
- 0:56
– led to a whole science surrounding computation, which evolved into the modern discipline of…
- 1:00
you guessed it!
- 1:01
Computer Science!
- 1:02
INTRO
- 1:11
One of the most storied algorithmic problems in all of computer science is sorting… as
- 1:15
in sorting names or sorting numbers.
- 1:18
Computers sort all the time.
- 1:19
Looking for the cheapest airfare, arranging your email by most recently sent, or scrolling
- 1:23
your contacts by last name -- those all require sorting.
- 1:27
You might think “sorting isn’t so tough… how many algorithms can there possibly be?”
- 1:30
The answer is: a lot.
- 1:32
Computer Scientists have spent decades inventing algorithms for sorting, with cool names like
- 1:36
Bubble Sort and Spaghetti Sort.
- 1:38
Let’s try sorting!
- 1:39
Imagine we have a set of airfare prices to Indianapolis.
- 1:42
We’ll talk about how data like this is represented in memory next week, but for now, a series
- 1:47
of items like this is called an array.
- 1:49
Let’s take a look at these numbers to help see how we might sort this programmatically.
- 1:52
We’ll start with a simple algorithm.
- 1:55
First, let’s scan down the array to find the smallest number.
- 1:58
Starting at the top with 307.
- 1:59
It’s the only number we’ve seen, so it’s also the smallest.


