- Computers only understand zeroes and ones, an alphabet called binary. While humans use decimal, which has 10 digits 0-9, computers only understand binary, which has two digits, 0 and 1.
- Now we can do more, by using ASCII, a standard that maps numbers to letters. For example,
A
is mapped to65
,B
is66
, etc. Though bits can only store numbers, programs can translate those bits to letters for humans to easily read.
Algorithms
- Algorithms are sets of instructions to solve particular problems, taking inputs and producing outputs that are hopefully correct, but also efficient.
The famous phone book example:
- We can open to the first page, and look for someone, say, Mike Smith. Then we continue to the second, third, and so on until we find Mike Smith. That algorithm is correct because we will find him eventually, but isn’t very fast.
- Humans reasonably open to the middle, and since the phone book is alphabetical and the middle is the M section, we can literally tear this problem in half by ripping the phone book in half and keeping only the half that we think Mike Smith is in.
- The green line will have a logarithmic slope that doesn’t increase in height as much as the other lines. With the phone book, even if the size of the phone book doubled, it would only take one more step to solve the problem.
Pseudocode is describing code for a problem in English:
1pick up phone book
2open to middle of phone book
3look at names
4if "Smith" is among names
5 call Mike
6else if "Smith" is earlier in book
7 open to middle of left half of book
8 go to line 3
9else if "Smith" is later in book
10 open to middle of right half of book
11 go to line 3
12else
13 give up
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.