Programming, problem solving, and algorithms

CPSC 203, 2026 W1

September 17, 2026

Announcements

  • POTW1 and Lab1 are due Sunday at 8pm.
    • POTW2 and Lab2 will become available after that.
  • Enroll in CPSC203 on PrairieTest.
    • Book your slot for examlet 1 (Thur Oct 1 - Mon Oct 5).
    • Students with accommodations: If you cannot see your accommodation when you try to book a slot, email me.
  • First practice examlet will become available on Monday.
    • Covers same material as examlet 1.

Today’s Plan

  • Data vs Information
    • Symbols can have multiple meanings
  • Representation in computers
    • Computer hardware interprets electrical signals as binary digits (“bits”).
    • We can use bits to represent numbers, and numbers to represent virtually anything.

Data vs Information

Data vs Information

  • You care about information.
  • Programs can process data

Multiple Interpretations

  • What do the following English words mean?
    • produce
    • contest
    • object
    • console
  • What does this colour mean?

Multiple Representations

  • How can we represent this colour?
  • Words

    • red (english)
    • rouge (french)
    • ckʷim (hən̓q̓əmin̓əm̓)
    • pula (tagalog)
    • 红色 (simplified Chinese)
  • Numbers

    • (255, 0, 0)
    • #FF0000

How to Design Data / Functions / Programs

Computer Representation

Representation

Today we’re exploring a fundamental question: How do we represent the world as data?

Note that “representation” has (at least) two meanings:

  • Technical: How computers encode rich concepts (like colour) as numbers
  • Social: Who is represented in this discipline, and why it matters

Computer Data

What does data look like to a computer?

Close-up of a solid-state drive (SSD) circuit board showing memory chips and connectors.

But Humans use Decimal Numbers

3 1 5 7
103 = 1000 102 = 100 101 = 10 100 = 1

Converting between Bases

1 1 0 1
[2]3 = 8 [2]2 = 4 [2]1 = 2 [2]0 = 1

Your turn: Thinking about bits

  • What’s the largest number you can represent with 4 bits?
  • How many bits do you need to represent 120?
  • If I give you one more bit, what happens to how many numbers you can represent?
  • How high can you count on your fingers? and toes?
  • As the number \(k\) grows, how does the number of digits grow?

From bits to… everything?

We can represent integers, so we can assign integers to any other (discrete) data

Let’s see how this works with colour.

Colour

Colour Interpretation

How does light wavelength become colour? Biological interpretation

What’s your favorite colour? Psychological interpretation

Does that colour influence your dress/decor/purchases? Cultural interpretation

Human Colour Perception

  • Human color vision has three channels
    • Our brain experiences color based on the intensity of light detected by “red”, “green” and “blue” cone cells in our retinas
  • If we are shown a yellow wavelength
    • L cones will respond strongly
    • M cones will respond almost as strongly
    • S cones will respond weakly
  • To fake a yellow wavelength (for a human)
    • Show a lot of a red wavelength
    • Show a little less of a green wavelength
    • Show little or no blue wavelength


Colour Representation

  • So we only need to figure out how to manage blends of three colors!

  • Can we use integers to represent colours?

    • One way: RGB or (red, green, blue), where each “component” is integer in the range 0 through 255.
    • For example: (255, 0, 127) == ?
    • Fun calculator for colour values: https://colorizer.org
  • Why 256 possible values?

Aside: Other Colour Representations

  • There are alternative ways to represent colour.
    • HSV (hue, saturation, value) is closer to how humans usually pick colours.
    • CMY (cyan, magenta, yellow) for reflective colour.
    • Sometimes you want more than three channels:
      • “Alpha” for controlling transparency.
      • CMYK to allow for proper black.
      • Additional wavelengths for sensors operating outside human capability.

Colour Representation Example

0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 1

  • What colour is this?

  • Easier to read if we use hexadecimal (base-16) representation:

    • A hex “digit” is one of 0123456789abcdef
    • One hex digit can represent the same as four binary digits

0 1 0 1 | 1 0 1 1 | 0 1 0 1 | 1 0 1 1 | 0 1 0 1 | 1 0 1 1

5 | b | 5 | b | 5 | b

Practice

What colour is this 24-bit number?

0110 0111 0100 1110 1010 0111



  • First: convert to hex using digits 0123456789abcdef