Computational Thinking

Joel Gethin Lewis

Lecture 1: Counting

What I'm going to talk about now:

  1. Counting in decimal, unary and binary.
  2. Memory in computers, storing numbers and words.
  3. How big things are.
  4. Bonus: really, really, really big numbers.

1. Counting in decimal, unary and binary.

  • Counting is using groups of symbols to represent quantities or amounts.
  • Let's count to 100 in Decimal. When do we need a extra digits?
  • Let's count to 10 in Unary.
  • Let's count to 20 in Binary. When do we need an extra digit?
  • What's the biggest number you can count to on your fingers? On your fingers and toes?

2. Memory in computers, storing numbers and words.

  • Computers use binary to represent everything in memory.
  • A bit is a Binary digIT.
  • A byte is eight bits. (BEight).
  • A kilobyte is 1,024 (2^10) bytes, mostly.
  • A megabyte is 1,048,576 (2^20) bytes, mostly.

2. Memory in computers, storing numbers and words (continued).

  • One megabyte is approximately one minute of 128 kbit/s MP3 compressed music.
  • One megabyte is six seconds of uncompressed CD audio.
  • One megabyte is a typical English book volume in plain text format (500 pages × 2000 characters per page).
  • The human genome consists of DNA representing 800 MB of data. The parts that differentiate one person from another can be compressed to 4 MB!

2. Memory in computers, storing numbers and words (continued).

  • There are different ways of storing numbers and words in computers, as whole these values are known as Data types.
  • Whole numbers or Integers are stored as ints. E.g. 0, 5, -567.
  • Numbers which are in between whole numbers are stored as Floating Points or floats. E.g. 3.142 or -5.66343.
  • As these numbers are stored in certain amounts of memory, if they get too big (or negative, or precise) the computer can run out of memory to store them, or overflow. This is bad. See the Y2K bug.

2. Memory in computers, storing numbers and words (continued).

  • You can also store individual characters of the alphabet as chars.
  • However, there are different encodings of characters - ASCII and Unicode for example - which allow different character sets to be displayed.
  • You can store words (multiple characters) in strings - which are actually just lists of chars.
  • Another name for lists are arrays.
  • Strings are one dimensional arrays. We'll be discussing two dimensional arrays next time.
  • Data can be stored as fixed values (constants) or values that can change (variables).

3. How big things are.

  • Thanks to Terrence J. Sejnowski and his article on Edge.org for the following examples.
  • How many seconds are there in a lifetime? 10^9 seconds.
  • A second is an arbitrary time unit, but one that is based on our experience. Our visual system is bombarded by snapshots at a rate of around 3 per second caused by rapid eye movements called saccades. Athletes often win or lose a race by a fraction of a second. If you earned a dollar for every second in your life you would be a billionaire. However, a second can feel like a minute in front of an audience and a quiet weekend can disappear in a flash. As a child, a summer seemed to last forever, but as an adult, summer is over almost before it begins. William James speculated that subjective time was measured in novel experiences, which become rarer as you get older. Perhaps life is lived on a logarithmic time scale, compressed toward the end.

3. How big things are (continued).

  • What is the GDP of the world? $10^14.
  • A billion dollars was once worth a lot, but there is now a long list of multibillionaires. The US government recently stimulated the world economy by loaning several trillion dollars to banks. It is difficult to grasp how much a trillion dollars ($10^12) represents, but several clever videos on YouTube (key words: trillion dollars) illustrate this with physical comparisons (a giant pile of $100 bills) and what you can buy with it (10 years of US response to 9/11). When you start thinking about the world economy, the trillions of dollars add up. A trillion here, a trillion there, pretty soon your talking about real money. But so far there aren't any trillionaires.

3. How big things are (continued).

  • How many synapses are there in the brain? 10^15.
  • Two neurons can communicate with each other at a synapse, which is the computational unit in the brain. The typical cortical synapse is less than a micron in diameter (10^-6 metres), near the resolution limit of the light microscope. If the economy of the world is a stretch for us to contemplate, thinking about all the synapses in your head is mind boggling. If I had a dollar for every synapse in your brain I could support the current economy of the world for 10 years. Cortical neurons on average fire once a second, which implies a bandwidth of around 10^15 bits per second, greater than the total bandwidth of the internet backbone.

3. How big things are (continued).

  • How many seconds will the sun shine? 10^17 seconds
  • Our sun has shined for billions of years and will continue to shine for billions more. The universe seems to be standing still during our lifetime, but on longer time scales the universe is filled with events of enormous violence. The spatial scales are also immense. Our space-time trajectory is a very tiny part of the universe, but we can at least attach powers of 10 to it and put it into perspective.

3. How big things are (continued).

  • Artwork: Powers of Ten by the Eames Office

4. Bonus: Really really really big numbers

Thanks!