Data Representation Examples in CS Thinking

Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Data Representation.

This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.

Concept Recap

The way information—numbers, text, images, and sound—is encoded as binary digits (0s and 1s) inside a computer. Different encoding schemes map real-world data to binary patterns, such as ASCII/Unicode for text, RGB for colors, and sampling for audio.

Turning real-world things (text, images, sound) into numbers a computer can process.

Read the full concept explanation →

How to Use These Examples

  • Read the first worked example with the solution open so the structure is clear.
  • Try the practice problems before revealing each solution.
  • Use the related concepts and background knowledge badges if you feel stuck.

What to Focus On

Core idea: All data in computers is ultimately numbers—representation is the mapping.

Common stuck point: Different representations have trade-offs (quality vs. size).

Sense of Study hint: When learning about data representation, start with the simplest case: how integers map to binary. Then explore how text uses encoding tables (ASCII maps 'A' to 65). Finally, see how complex data like images and sound are broken into numbers that can be stored as binary.

Common Mistakes to Watch For

Before you work through the examples, skim the mistake guide so you know which shortcuts and sign errors to avoid.

Worked Examples

Example 1

easy
A computer stores the character 'A' as the number 65 (ASCII). Explain why computers use numbers to represent characters.

Answer

Computers only store binary numbers. Characters are represented by assigning each a unique number via an encoding scheme like ASCII.

First step

1
Step 1: Computers can only store binary numbers (sequences of 0s and 1s).

Full solution

  1. 2
    Step 2: To store text, each character is assigned a unique number using an encoding scheme like ASCII (A=65, B=66, etc.).
  2. 3
    Step 3: The binary for 65 is 01000001, which is what the computer actually stores. The encoding scheme maps between human-readable characters and binary.
Character encoding is a fundamental concept in data representation. ASCII uses 7 bits (128 characters), while Unicode extends this to represent characters from all writing systems worldwide.

Example 2

medium
Explain how a computer represents a colour image using binary. What are pixels and colour depth?

Example 3

easy
A pixel uses 11 byte for grayscale brightness (00=black, 255255=white). How many distinct shades are possible?

Example 4

medium
The word 'CAT' is stored in ASCII with C=67, A=65, T=84. How many bytes does it take using 11 byte per character?

Example 5

medium
A grayscale image is 640×480640 \times 480 with 88 bits per pixel. What is its uncompressed size in kilobytes (use 11 KB =1000= 1000 bytes)?

Example 6

hard
You want to encode the 2626 uppercase English letters using a fixed-length binary code. What is the minimum number of bits per letter, and how many unused codes remain?

Example 7

challenge
An 8-bit unsigned register holds 250250 and is incremented by 1010. What value does the register show, and what is the phenomenon called?

Practice Problems

Try these problems on your own first, then open the solution to compare your method.

Example 1

medium
Sound is analogue but computers are digital. Describe how analogue sound is converted to digital form, using the terms 'sample rate' and 'bit depth'.

Example 2

hard
Explain the difference between lossless and lossy compression. Give an example of each and explain when you would choose one over the other.

Example 3

easy
Convert the binary number 101121011_2 to decimal.

Example 4

easy
Convert decimal 55 to binary.

Example 5

easy
How many distinct values can 88 bits represent?

Example 6

easy
What is 255255 in binary (8 bits)?

Example 7

easy
A color uses one byte each for R, G, B. How many bits total?

Example 8

easy
In ASCII, the letter 'A' is 6565. What decimal code is 'B'?

Example 9

easy
True or false: the same image can be stored as PNG or JPEG with different trade-offs.

Example 10

easy
Doubling the bits per audio sample tends to do what to file size?

Example 11

medium
Convert 110121101_2 to decimal, then add 33.

Example 12

medium
Convert decimal 2626 to binary.

Example 13

medium
How many bits are needed to represent at least 10001000 distinct values?

Example 14

medium
The word 'Hi' is stored in ASCII ('H'=72, 'i'=105). How many bytes does it take (1 byte/char)?

Example 15

medium
UTF-16 uses 2 bytes per character; ASCII uses 1. Storing 100 ASCII letters in each, how many more bytes does UTF-16 use?

Example 16

medium
A grayscale image is 4×44\times 4 pixels, 1 byte per pixel. How many bits to store it?

Example 17

medium
Add the binary numbers 1012+0112101_2 + 011_2. Give the binary result.

Example 18

medium
Convert the binary 10010210010_2 to decimal.

Example 19

medium
A file uses 2 bytes per character. How many bits does a 10-character string take?

Example 20

challenge
An 8-bit unsigned counter holds 255255 and is incremented by 1. What value results, and what is this phenomenon called?

Example 21

challenge
Why can the decimal fraction 0.10.1 not be stored exactly in binary floating point? Give the core reason.

Example 22

challenge
Design a fixed-length encoding for the 4 directions N, E, S, W. What is the minimum bits per symbol, and give one valid assignment?

Example 23

easy
Convert the binary number 1102110_2 to decimal.

Example 24

easy
Convert decimal 99 to binary.

Example 25

easy
How many bytes are in 1616 bits?

Example 26

medium
Convert 10101210101_2 to decimal.

Example 27

medium
Convert decimal 4242 to binary.

Example 28

medium
How many bits are needed to represent at least 5050 distinct values?

Example 29

medium
An image is 100×100100 \times 100 pixels with 2424-bit color. What is its uncompressed size in bytes?

Example 30

medium
Add 1102+1012110_2 + 101_2. Give the binary result.

Example 31

medium
Convert decimal 100100 to binary.

Example 32

medium
Convert 11111211111_2 to decimal.

Example 33

hard
A song is 33 minutes long, sampled at 4410044100 Hz, stereo (2 channels), 1616 bits/sample. What is the uncompressed file size in megabytes (use 11 MB =106= 10^6 bytes)?

Example 34

hard
Convert decimal 200200 to binary (8 bits).

Example 35

hard
Two characters in ASCII are stored as 01001000 0110100101001000\ 01101001. What word is this?

Example 36

hard
A PNG of a photo is 2.52.5 MB; the same photo saved as JPEG is 0.40.4 MB but slightly blurry. What kind of compression is each, and why is JPEG smaller?

Example 37

challenge
A signed 8-bit two's complement byte stores 1-1. Give the bit pattern.

Example 38

challenge
You design a 3-bit code for 88 symbols, but later need a 9th symbol. What is the minimum number of bits needed now, and what is the cost in storage for 10001000 symbols?

Background Knowledge

These ideas may be useful before you work through the harder examples.

binarybits bytes