Lompat ke konten

Representasi informasi

Ilmu Komputer A-Level · Topik 1

Pelajaran video untuk topik ini Buka halaman video
21:58

Sistem Angka & Data

Foto ini. Lagu ini. Video ini. Nama Anda, pesan Anda, setiap file di setiap perangkat—di dalam komputer, semuanya hanyalah nol dan satu.…

Narasi bahasa Inggris · takarir bahasa Inggris dan 中文 yang dapat dipilih

1.1

Sistem bilangan

Silabus
Kandidat harus mampu: Catatan dan panduan
Tunjukkan pemahaman tentang besaran biner dan perbedaan antara awalan biner dan awalan desimal Pahami perbedaan dan gunakan: • kibi dan kilo • mebi dan mega • gibi dan giga • tebi dan tera
Tunjukkan pemahaman tentang berbagai sistem bilangan Gunakan basis bilangan biner, desimal, heksadesimal serta representasi Binary Coded Decimal (BCD), complement satu, dan complement dua untuk bilangan biner
Konversi nilai integer dari satu basis bilangan/representasi ke representasi lainnya
Lakukan penjumlahan dan pengurangan biner Menggunakan integer biner positif dan negatif
Tunjukkan pemahaman tentang bagaimana overflow dapat terjadi
Jelaskan aplikasi praktis di mana Binary Coded Decimal (BCD) dan Heksadesimal digunakan
Tunjukkan pemahaman dan mampu merepresentasikan data karakter dalam bentuk biner internalnya, tergantung pada set karakter yang digunakan Siswa diharapkan familiar dengan ASCII (American Standard Code for Information Interchange), ASCII diperluas, dan Unicode. Siswa tidak diharuskan menghafal kode karakter tertentu

Sumber: Silabus Cambridge International

English
Counting in binary: 0 to 15

The three number systems 数制 you must use:

  • denary 十进制 (decimal, base 10) — uses digits 0–9. Place values are powers of ten.
  • binary 二进制 (base 2) — uses 0 and 1. Place values are powers of two. Every byte 字节 is 8 bits 位.
  • hexadecimal 十六进制 (base 16) — uses 0–9 then A–F for 10–15. Each hex digit 数位 stands for exactly 4 bits.
Beads on a traditional abacus
An abacus represents numbers by place value — the same idea behind decimal, binary and hexadecimal

Conversions

Denary → binary: keep dividing by 2 and record the remainders, read bottom-up. Or subtract the largest place value 位值 (power of 2) that fits.

Example: $558_{10}$: $558 = 512 + 32 + 8 + 4 + 2 = 2^{9} + 2^{5} + 2^{3} + 2^{2} + 2^{1}$. In 12 bits: 0010 0010 1110.

Binary → hex: group the bits into nibbles 半字节 (4 bits) from the right and convert each. 0010 0010 1110 → 2 2 E → 22E.

Hex → binary: replace each hex digit with its 4-bit pattern. Hex → denary: multiply each digit by its place value. 22E $= 2 \times 256 + 2 \times 16 + 14 = 558$.

Worked example. Convert denary 200 to 8-bit binary, then to hexadecimal.

$200 = 128 + 64 + 8$, so the binary is 11001000. In nibbles, 1100 1000 $= 12$ and $8$, i.e. $\text{C}$ and $8$, so the hexadecimal is C8.

A binary place-value chart for 200: the columns 128, 64, 32, 16, 8, 4, 2, 1 hold the bits 1,1,0,0,1,0,0,0; the two 4-bit nibbles 1100 and 1000 become the hex digits C and 8, so 200 = 11001000 = C8
Reading 200 from its place values, then grouping the bits into nibbles to get hex C8

How many bits?

Exam questions fix the register width 寄存器宽度 (8, 12 or 16 bits). Pad with leading zeros to that width: $558$ in 12 bits is 0010 0010 1110, never 10 0010 1110.

To find the minimum number of bits that can store a value, ask which place values you need:

  • an unsigned integer from $0$ to $2^{n} - 1$ needs $n$ bits: $200$ needs 8 bits (the top is $255$), $1000$ needs 10 bits (the top is $1023$), $16$ needs 5 bits (4 bits stop at $15$).
  • a signed two's-complement integer from $-2^{n-1}$ to $2^{n-1} - 1$ needs $n$ bits: $-200$ needs 9 bits, because 8 bits stop at $-128$.
  • one hexadecimal digit needs 4 bits, one BCD digit needs 4 bits, and one ASCII character needs 7 bits (8 for extended ASCII).

Binary vs decimal prefixes

Two prefix families look similar but differ — decimal (powers of 10) and binary (powers of 2):

Decimal (SI) Binary (memory)
kilo $= 10^{3}$ kibi (Ki) $= 2^{10} = 1024$
mega $= 10^{6}$ mebi (Mi) $= 2^{20}$
giga $= 10^{9}$ gibi (Gi) $= 2^{30}$
tera $= 10^{12}$ tebi (Ti) $= 2^{40}$

So a tebibyte (TiB) is slightly more than a terabyte (TB). A "1 TB" drive holds $10^{12}$ bytes, but an operating system that reports in TiB shows a smaller number.

Jelajahi

Binier, desimal, dan heksadesimal

Ketik angka dan lihat dalam biner, desimal, dan heksadesimal sekaligus — dan bagaimana nilai tempatnya bertambah.

Kosa kata Latih
English Bahasa Indonesia
number system/ˈnʌmbə ˈsɪstəm/ sistem bilangan
binary/ˈbaɪnəri/ biner
denary/ˈdiːnəri/ desimal
digit/ˈdɪdʒɪt/ digit
place value/pleɪs ˈvæljuː/ nilai tempat
byte/baɪt/ byte
bit/bɪt/ bit
hexadecimal/ˌheksəˈdesɪml/ heksadesimal
nibble/ˈnɪbl/ nibble
register width/ˈredʒɪstə wɪtθ/ lebar register
1.1

Aritmatika biner

English

Binary addition

Add column by column from the right, carrying as in denary:

8-bit binary addition of 118 and 48 with the carry bits shown in red above the left columns, giving 166
Adding column by column; the carries ripple to the left. 118 + 48 = 166
Bit A Bit B Carry in Sum bit Carry out
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 1 0 0 1
1 1 1 1 1

Overflow 溢出 happens when the result needs more bits than the register 寄存器 can hold — the carry-out of the leftmost column is the overflow bit.

Worked example. Add the 8-bit unsigned integers $10110101$ and $01101100$, and comment on the result.

$10110101 + 01101100 = 1\,00100001$. The answer needs 9 bits, so it does not fit in an 8-bit register: overflow has occurred. A full answer names the error and says why, using the word size the question gave: "Overflow: the true result ($289$) is larger than the largest value an 8-bit register can hold ($255$), so the carry out of the most significant bit is lost and the stored result ($00100001 = 33$) is wrong."

Binary subtraction

The usual way is two's complement 补码 addition: to do $A - B$, form the two's complement of $B$ (invert every bit and add 1), then add, and discard any final carry-out.

To subtract $00011110$ from $01100100$ (unsigned 8-bit):

  • two's complement of $00011110$: invert → $11100001$, add 1 → $11100010$.
  • add to $01100100$: result $1\,01000110$ (9 bits) — discard the leading 1 → $01000110 = 70_{10}$. Check: $100 - 30 = 70$. ✓

Two's complement signed integers

In an $n$-bit two's-complement number:

  • the most significant bit 最高有效位 (MSB) is the sign bit 符号位: 0 = positive, 1 = negative.
  • to read a negative number: invert every bit, add 1, then negate.

So $11100010$ is negative; invert → $00011101$, add 1 → $00011110 = 30$, so it is $-30$. This is a signed integer 有符号整数 (unlike an unsigned 无符号 one). The range for $n$ bits is $-2^{n-1}$ to $+2^{n-1} - 1$; for 8 bits, $-128$ ($10000000$) to $+127$ ($01111111$).

The same bits mean different numbers depending on the agreed reading. As an unsigned integer every bit is a place value, so 8 bits run from $0$ to $255$; as a signed two's-complement integer the top bit is the sign, so the same 8 bits run from $-128$ to $+127$. The pattern $11111111$ is $255$ read one way and $-1$ read the other — nothing in the bits themselves says which.

A table of four 8-bit patterns read twice: 00000000 is 0 either way, 01111111 is 127 unsigned and +127 signed, 10000000 is 128 unsigned but -128 signed, and 11111111 is 255 unsigned but -1 signed The same byte read as unsigned and as signed: only the agreed interpretation tells them apart An 8-bit two's-complement number line from -128 (10000000) to +127 (01111111); numbers with sign bit 1 are negative and those with sign bit 0 are positive, with -1 = 11111111 sitting just below 0 = 00000000 8-bit two's complement: the sign bit splits the range into negative ($-128$ to $-1$) and positive ($0$ to $127$)

Worked example. What denary value does the 8-bit two's-complement number $10110100$ represent?

The MSB is 1, so it is negative. Invert → $01001011$, add 1 → $01001100 = 76$, so the value is $-76$. Check with place values: $-128 + 32 + 16 + 4 = -76$.

Worked example. Write $-108$ as a 12-bit two's-complement integer.

Start from $+108$ in 12 bits: $108 = 64 + 32 + 8 + 4$, so 0000 0110 1100. Invert every bit: 1111 1001 0011. Add 1: 1111 1001 0100. Check with place values, where the top bit is worth $-2^{11} = -2048$: $-2048 + 1024 + 512 + 256 + 128 + 16 + 4 = -108$. ✓

For 12 bits the range is $-2048$ (1000 0000 0000) to $+2047$ (0111 1111 1111). Questions that ask for the smallest and largest values want these two patterns, so learn the rule: the most negative number is a 1 followed by zeros; the most positive is a 0 followed by ones.

An arithmetic shift 算术移位 moves every bit left or right but keeps the sign: a shift right by one place halves the value and copies the sign bit into the empty space on the left, so a negative number stays negative (1111 1001 0100 shifted right three places is 1111 1111 0010, which is $-14$: $-108 / 8 = -13.5$, and a shift right rounds down). A shift left doubles the value. Shifts belong to the assembly instruction set in topic 4, but this question is asked with the number work here.

Overflow in signed arithmetic happens when the true result falls outside this range — spotted when the sign bit flips wrongly (two positives giving a negative, or two negatives giving a positive).

One's complement

Before two's complement, an older scheme called one's complement 反码 represented a negative number by simply inverting every bit of the positive — there is no "add 1" step.

  • $+30 = 00011110$, so in one's complement $-30 = 11100001$ (just the inverse).
  • Drawback: it has two zeros — $00000000$ ($+0$) and $11111111$ ($-0$) — which wastes a bit pattern and makes arithmetic awkward.

Two's complement (invert and add 1) removes the negative zero: it has a single zero and lets addition and subtraction use the same circuit. That is why modern computers store signed integers in two's complement, not one's complement.

Jelajahi

Biner & bilangan bulat bertanda

byte = Σ nilai tempat

Lihat bagaimana pola 8-bit memetakan ke angka (dan bagaimana cara melampaui 255).

Jelajahi

Bit bertanda dua komplemen

Bit paling kiri memiliki nilai tempat negatif. Balik setiap bit — atau tekan Negate (balik setiap bit, lalu tambah 1) — dan lihat perubahan nilai bertandanya.

Kosa kata Latih
English Bahasa Indonesia
register/ˈredʒɪstə/ register
unsigned/ʌnˈsaɪnd/ tanpa tanda
overflow/ˌəʊvəˈfləʊ/ overflow
most significant bit/məʊst sɪɡˈnɪfɪkənt bɪt/ bit signifikan tertinggi
two's complement/tuːz ˈkɒmplɪmənt/ komplemen dua
signed integer/saɪnd ˈɪntɪdʒə/ Bilangan bulat bertanda
sign bit/saɪn bɪt/ bit tanda
arithmetic shift/ˌærɪθˈmetɪk ʃɪft/ Geser aritmatika
one's complement/wʌnz ˈkɒmplɪmənt/ komplemen satu
1.1

Desimal Kode Biner (BCD)

English

In BCD 二进码十进数, each denary digit is written as its own 4-bit pattern. The number $93$ is 1001 0011 in BCD — not binary 93 ($01011101$). Each nibble uses only 0–9; patterns $1010$–$1111$ are invalid.

BCD reading: 0010 0111 0101 → 2, 7, 5 → 275.

Use: calculators, digital clocks, and devices that show denary digits — each digit drives a 7-segment display 七段显示器. Currency code often uses BCD to avoid the rounding errors of converting fractions like 0.1 to binary.

A "justify" answer must link the use to a property of BCD: each denary digit has its own 4 bits, so a digit can be sent straight to its display, or added digit by digit, with no conversion of the whole number; and a decimal fraction such as $0.10$ is stored exactly, which a binary fraction cannot do.

A single-digit seven-segment LED display component, showing its seven separate bars
A seven-segment display shows one denary digit, often driven by BCD
Kosa kata Latih
English Bahasa Indonesia
BCD/ˌbiː siː ˈdiː/ Kode BCD
7-segment display/ˈsevən ˈseɡmənt dɪˈspleɪ/ Tampilan 7-segmen
1.1

Heksadesimal — kegunaan praktis

English

Hex is a compact way to write binary (1 hex digit = 4 bits):

A byte splits into two nibbles; each nibble is one hexadecimal digit
A byte is two nibbles; each nibble is one hex digit
  • memory addresses 内存地址 in low-level programming — 0x7FFE.
  • colour values in HTML/CSS — #FF8800.
  • MAC addresses — AC:DE:48:00:11:22.

Hex does not change the stored data — it just makes binary easier for humans.

Kosa kata Latih
English Bahasa Indonesia
memory address/ˈmeməri əˈdres/ Alamat memori
1.1

Kode karakter

English

Computers store text as numbers; each character has a numeric code point 码点 set by a character set 字符集.

ASCII

  • ASCII uses 7 bits — 128 code points. Basic Latin letters, digits, punctuation, and control codes.
  • Extended ASCII uses 8 bits — 256 code points; the lower 128 match ASCII, the upper 128 vary by region.
A small ASCII table: the character A is code 65 = 01000001, a is 97 = 01100001, the digit 0 is 48 = 00110000, and space is 32 = 00100000
Each character is stored as a number — a few ASCII code points in denary and binary

Unicode

  • Unicode is a universal character set covering almost every script, plus symbols and emoji.
  • common encodings 编码: UTF-8 (1–4 bytes, ASCII-compatible), UTF-16 (2 or 4 bytes), UTF-32 (fixed 4 bytes).

Why Unicode beats ASCII

  • it represents far more characters (every script, emoji); ASCII covers only basic English.
  • files are portable with no code-page confusion, and allow multilingual text in one document.
  • trade-off: Unicode files are usually larger for English-only text.

When a question asks for differences, give them in pairs with numbers: ASCII uses 7 bits (extended ASCII 8), so 128 (256) characters; Unicode uses up to 32 bits (UTF-8 uses 1 to 4 bytes), so more than a million code points. ASCII covers basic English only; Unicode covers every script, and its first 128 code points are the ASCII ones. In UTF-8 an English letter still takes 1 byte, so a 40-letter English file name is 40 bytes in ASCII and in UTF-8 alike, while a Chinese character takes 3 bytes.

Jelajahi

Sebuah karakter disimpan sebagai angka

Setiap karakter memiliki kode angka — 'A' adalah 65. Balik bit untuk melihat kode tersebut dalam biner dan heksadesimal, persis seperti cara komputer menyimpannya.

Kosa kata Latih
English Bahasa Indonesia
code point/kəʊd pɔɪnt/ titik kode
character set/ˈkærɪktə set/ himpunan karakter
encoding/enˈkəʊdɪŋ/ pengkodean
1.2

Bitmap images

Silabus
Kandidat harus mampu: Catatan dan panduan
Tunjukkan pemahaman tentang bagaimana data untuk gambar bitmap dienkripsi Gunakan dan pahami istilah: pixel, header file, resolusi gambar, resolusi layar, kedalaman warna / bit depth
Lakukan perhitungan untuk memperkirakan ukuran file untuk gambar bitmap
Tunjukkan pemahaman tentang efek perubahan elemen pada gambar bitmap terhadap kualitas gambar dan ukuran file Gunakan istilah: resolusi gambar, kedalaman warna / bit depth
Tunjukkan pemahaman tentang bagaimana data untuk grafik vektor dienkripsi Gunakan istilah: objek gambar, properti, daftar gambar
Justifikasi penggunaan gambar bitmap atau grafik vektor untuk tugas tertentu
Tunjukkan pemahaman tentang bagaimana suara direpresentasikan dan dienkripsi Gunakan istilah: penyampelan, tingkat penyampelan, resolusi penyampelan, data analog dan data digital
Tunjukkan pemahaman tentang dampak perubahan tingkat penyampelan dan resolusi Termasuk dampak terhadap ukuran file dan akurasi

Sumber: Silabus Cambridge International

English

A bitmap 位图 image (also called a bitmapped image) stores the colour of every pixel 像素 in a grid. At the start of the file a file header 文件头 records the image's metadata — its width, height and colour depth — so software knows how to read the pixel data that follows.

  • image resolution 图像分辨率: the bitmap's own size, width × height in pixels (e.g. 1920 × 1080).
  • screen resolution 屏幕分辨率: the width × height the display can show. If an image's resolution is larger than the screen it is scaled down to fit; a low-resolution image looks blocky when stretched onto a higher-resolution screen.
  • colour depth 颜色深度 (bit depth 位深度): bits per pixel. 1 bit → black/white; 8 bits → 256 colours; 24 bits → 16.7 million ("true colour").
The same disc stored on three pixel grids, A to C, getting blockier as the pixels grow larger and fewer
The same image stored at three resolutions, from high (A) to low (C): fewer, larger pixels mean less detail

File size

$$\text{size in bits} = \text{width} \times \text{height} \times \text{bit depth}.$$

Divide by 8 for bytes, by 1024 for KiB, etc. Example: a $3000 \times 2000$ image at 24 bpp is $3000 \times 2000 \times 24 = 1.44 \times 10^{8}$ bits $\approx 17.2\ \text{MiB}$.

A 6 by 4 grid of pixels with its width and height labelled; pixels = 6 times 4 = 24, and at 8 bits per pixel the size = 24 times 8 = 192 bits
The same formula on small numbers: count the pixels, then multiply by the colour depth

State the units you used. The mark scheme accepts $1\ \text{MB} = 10^{6}$ bytes (the SI prefix) or $1\ \text{MiB} = 1024 \times 1024$ bytes (the binary prefix), as long as your working shows which one; the same image is $18.0\ \text{MB}$ or $17.2\ \text{MiB}$. Add the size of the file header if the question gives one.

A video is a sequence of bitmap images, each one a frame 帧. Before compression its size is the size of one frame $\times$ the frame rate 帧率 (frames per second) $\times$ the duration in seconds: 30 frames per second of $1920 \times 1080$ pixels at 24 bits is $30 \times 1920 \times 1080 \times 24 \approx 1.5 \times 10^{9}$ bits, about $187\ \text{MB}$, for every second. That is why video is always compressed.

Changing settings

  • lower resolution → smaller file, less detail (looks blocky when enlarged).
  • lower colour depth → smaller file, but smooth shades show banding.
  • higher of either → larger file, better quality.
Kosa kata Latih
English Bahasa Indonesia
bitmap/ˈbɪtmæp/ bittmap
pixel/ˈpɪksl/ piksel
file header/faɪl ˈhedə/ header file
colour depth/ˈkʌlə depθ/ kedalaman warna
image resolution/ˈɪmɪdʒ ˌrezəˈluːʃn/ resolusi gambar
screen resolution/skriːn ˌrezəˈluːʃn/ resolusi layar
bit depth/bɪt depθ/ Kedalaman bit
frame/freɪm/ bingkai
frame rate/freɪm reɪt/ tingkat bingkai
1.2

Grafik vektor

English

A vector graphic 矢量图形 stores the instructions to draw the image as a drawing list 绘图列表 — an ordered list of drawing objects 绘图对象 (geometric primitives 图元: lines, curves, polygons, circles). Each drawing object has properties 属性 such as colour, fill, line width and position (coordinates). To show it, the program renders 渲染 the drawing list at any resolution needed.

A simple house drawing made from a rectangle body, triangle roof, circle window, door rectangle and a line, each labelled with its shape type and attributes
A vector image is built from labelled geometric shapes, each with attributes

Bitmap vs vector

Task Better choice Why
Photograph Bitmap Complex pixel-level detail can't be described as shapes.
Logo, icon, sign Vector Sharp edges; scales to any size without blur.
Engineering drawing Vector Precise geometry and scaling.
Painting, texture Bitmap Smooth tonal detail per area.

Vector advantage: it scales without losing quality — a vector logo stays sharp at any size, while a bitmap blurs when enlarged. Vector disadvantage: it cannot describe arbitrary pixel detail (photographs).

A "justify" answer links the choice to the task. "The logo must appear on a business card and on a billboard, so it should be a vector graphic: it is stored as drawing objects and is re-rendered sharply at any size, whereas a bitmap would show its pixels when enlarged." For a photograph the argument runs the other way: there are no shapes to describe, so every pixel's colour must be stored.

Side by side, both enlarged: a bitmap diagonal is a jagged staircase of pixels, while a vector diagonal stays a smooth straight line
Enlarged, a bitmap's pixels turn jagged; a vector stays smooth at any size
Jelajahi

Laboratorium konsep komputasi

Klasifikasikan contoh konkret berdasarkan ide komputasi yang ditunjukkannya.

Kosa kata Latih
English Bahasa Indonesia
vector graphic/ˈvektə ˈɡræfɪk/ Grafik vektor
drawing list/ˈdrɔːɪŋ lɪst/ daftar gambar
drawing objects/ˈdrɔːɪŋ ˈɒbdʒekts/ objek gambar
primitive/ˈprɪmɪtɪv/ Primitif
properties/ˈprɒpətiz/ sifat
render/ˈrendə/ rendering
1.2

Suara

English

A continuous wave of analogue data 模拟数据 (the sound) is converted into digital data 数字数据 by sampling 采样:

  • sampling rate 采样率 — samples per second (Hz). CD quality is $44.1\ \text{kHz}$.
  • sampling resolution 采样分辨率 (bit depth) — bits per sample's amplitude 振幅. CD quality is 16 bits.
A smooth analogue sound wave with vertical sample bars at regular time intervals, each bar reading the wave's amplitude
Sampling a sound wave: its amplitude is read at each time interval

File size

$$\text{size in bits} = \text{sampling rate} \times \text{resolution} \times \text{duration} \times \text{channels}.$$

A 10-second stereo CD clip: $44100 \times 16 \times 10 \times 2 = 14\,112\,000$ bits $\approx 1.68\ \text{MiB}$.

Changing settings

  • higher sampling rate → captures higher pitches, larger file.
  • higher sample resolution → finer amplitude steps, less quantisation 量化 noise, larger file.
  • lower of either → smaller file, clear quality loss.

(The sampling rate must be at least twice the highest frequency you want to keep.)

A sound wave crossed by evenly spaced sample lines, one dot per sample, noted as sampling rate = number of samples taken each second
The sampling rate is the number of samples taken each second
Jelajahi

Pengambilan sampel suara

y = a sin(bt + c)

Pengambilan sampel mengukur gelombang suara pada interval teratur — tingkat yang lebih tinggi menyalinnya lebih akurat.

Kosa kata Latih
English Bahasa Indonesia
analogue data/ˈænəlɒɡ ˈdeɪtə/ data analog
digital data/ˈdɪdʒɪtl ˈdeɪtə/ data digital
sampling/ˈsæmplɪŋ/ pencuplikan
sampling rate/ˈsæmplɪŋ reɪt/ tingkat pencuplikan
sampling resolution/ˈsæmplɪŋ ˌrezəˈluːʃn/ resolusi pencuplikan
amplitude/ˈæmplɪtjuːd/ amplitudo
sample resolution/ˈsæmpl ˌrezəˈluːʃn/ Resolusi sampel
quantisation/ˌkwɒntaɪˈzeɪʃn/ Kuantisasi
1.3

Kompresi

Silabus
Kandidat harus mampu: Catatan dan panduan
Tunjukkan pemahaman akan kebutuhan dan contoh penggunaan kompresi
Tunjukkan pemahaman tentang kompresi lossy dan lossless serta justifikasi penggunaan metode tertentu dalam situasi yang diberikan
Tunjukkan pemahaman tentang cara mengompresi file teks, gambar bitmap, grafik vektor, dan file suara Termasuk penggunaan pengkodean panjang run (RLE)

Sumber: Silabus Cambridge International

English

Compression 压缩 reduces file size, saving storage and transmission bandwidth 带宽. Two kinds:

  • lossless 无损 — the original data is recovered exactly (text, programs, ZIP/PNG).
  • lossy 有损 — some detail is dropped for much smaller files (JPEG, MP3, video).

When to use which

  • lossless for documents, source code, medical images — anything needing exact data.
  • lossy for streaming media. Real-time video streaming uses lossy compression because it must send huge amounts of data in real time over limited bandwidth; lossless would not shrink it enough. Raw HD video is gigabytes per minute, so without compression the picture would keep freezing.

A "justify" answer names the method, then the reason from the situation: "Lossless, because the spreadsheet must be restored exactly; a single changed value would make the accounts wrong." Or: "Lossy, because the photographs are viewed on a phone screen where the dropped detail is not visible, and the smaller files upload faster and use less storage."

Lossless methods

  • run-length encoding 行程编码 (RLE): store "the next $n$ values are $x$" instead of repeating $x$. Great for flat areas; useless for noisy data.
  • dictionary methods 字典编码 (ZIP, PNG): replace repeated byte sequences with a short reference. Good for text and code.
  • Huffman coding 霍夫曼编码: give short codes to common symbols and long codes to rare ones, bringing the average code length near the data's entropy 熵.

How each kind of file is compressed:

  • text file: dictionary methods and Huffman coding turn repeated words and common characters into short codes. Text must stay lossless, because one changed character changes the meaning.
  • bitmap image: RLE for runs of identical pixels (icons, diagrams, black-and-white scans); lossy JPEG for photographs, or a lower colour depth or resolution.
  • vector graphic: the drawing list is already small; remove drawing objects that are not needed, store coordinates to fewer decimal places, or apply a lossless method such as ZIP to the file.
  • sound file: lossy MP3 or AAC removes what the ear cannot hear; a lower sampling rate or resolution is also lossy; lossless formats keep every sample and shrink the file much less.
A 16-pixel row of 6 white, 4 black and 6 white cells; the three runs are bracketed and labelled 6W, 4B, 6W, so 16 pixels are stored as the 3 runs 6W 4B 6W
Run-length encoding on a single row: 16 pixels become 3 runs
An 8 by 8 black-and-white grid showing the letter F, with each row's binary pattern and its shorter run-length code listed beside it
Run-length encoding of the letter F in an $8\times8$ black-and-white grid
Dictionary coding worked through: the source ABC ABC ABC XYZ, a dictionary in which 1 stands for ABC and 2 stands for XYZ, and the encoded stream 1 1 1 2
Dictionary coding: each repeated sequence is stored once, and every occurrence becomes a short index
Huffman coding worked through on the word BANANA: the letter counts A 3, N 2 and B 1, the code tree built from them, and the resulting codes A = 0, B = 10, N = 11
Huffman coding: the commonest symbol gets the shortest code, so BANANA needs 10 bits instead of 12

Lossy methods

  • images (JPEG): drop fine detail and colour differences the eye barely sees.
  • sound (MP3, AAC): drop pitches we hear less well, and quiet sounds hidden by louder ones.
  • video combines spatial 空间 compression (within each frame, like JPEG) with temporal 时间 compression (most frames store only the differences from the previous frame).
A tree classifying compression into lossless (RLE, dictionary/ZIP/PNG, Huffman) and lossy (JPEG images, MP3/AAC sound, video) with examples under each branch
Compression methods: lossless versus lossy, with common examples

Logical and arithmetic shifts; IP address sizes

A logical shift moves the bit pattern and fills vacated positions with 0. In a right arithmetic shift of a two's-complement integer, the sign bit is copied into the new leftmost positions. For eight-bit 11110100 (−12), logical right by two gives 00111101 (61); arithmetic right by two gives 11111101 (−3). Discarded bits are lost; overflow and rounding can prevent shifts behaving like exact multiplication or division.

An IPv4 address has 32 bits, often shown as four eight-bit decimal groups. An IPv6 address has 128 bits, usually shown as eight groups of four hexadecimal digits before permitted abbreviation. These are address lengths, not numbers of characters in the printed address.

Jelajahi

Pengkodean panjang rentang

Saksikan deretan simbol berulang tertekan menjadi jumlah — kompresi tanpa kehilangan sederhana.

Kosa kata Latih
English Bahasa Indonesia
compression/kəmˈpreʃn/ kompresi
bandwidth/ˈbændwɪdθ/ lebar pita
lossless/ˈlɒsləs/ tanpa kehilangan
lossy/ˈlɒsi/ dengan kehilangan
run-length encoding/rʌn leŋθ enˈkəʊdɪŋ/ pengkodean panjang larian
dictionary methods/ˈdɪkʃənəri ˈmeθədz/ Metode kamus
Huffman coding/ˈhʌfmən ˈkəʊdɪŋ/ pengkodean Huffman
entropy/ˈentrəpi/ Entropi
spatial/ˈspeɪʃl/ spasial
temporal/ˈtempərəl/ temporal
1.3

Definisi yang diterima oleh penguji

English

A definition question is marked against fixed wording. Learn these exactly, and give one answer only.

Term Definition
bit a single binary digit, 0 or 1
byte a group of 8 bits
binary prefix a multiplier that is a power of 2 (kibi = 1024) rather than a power of 10 (kilo = 1000)
two's complement a way of representing signed integers in which the most significant bit has a negative place value
overflow the result of a calculation is too large to be represented in the number of bits available
Binary Coded Decimal each denary digit is stored as its own 4-bit binary pattern
character set the set of characters a computer can represent, each with its own binary code
pixel the smallest element of a bitmap image, storing one colour value
image resolution the number of pixels in an image, given as width by height
screen resolution the number of pixels a display can show, given as width by height
colour depth the number of bits used to store the colour of one pixel
sampling rate the number of samples of the sound taken per second
sampling resolution the number of bits used to store the amplitude of one sample
lossless compression compression from which the original data can be recovered exactly
lossy compression compression that permanently removes some data, so the original cannot be recovered
run-length encoding replacing a run of repeated values with one value and a count
1.3

Tips ujian

English
  • Show working for base conversions: denary → binary by place values, binary → hexadecimal in nibbles (groups of 4 bits).
  • For two's complement the MSB is negative; to negate, invert and add 1; watch for overflow when the sign bit flips wrongly.
  • Distinguish bitmap (pixels; file size $=$ width $\times$ height $\times$ colour depth) from vector (drawing commands; scales without loss).
  • Sound file size depends on sample rate $\times$ bit depth $\times$ time — more of each means better quality but a bigger file.
  • Compare lossless vs lossy compression and give a use for each.

Common mistakes

  • Explaining an overflow with "the answer was greater than 255" or "it has 9 bits". State the word size the question gave, then say the result cannot be represented in it.
  • Making a negative number by setting the top bit to 1 and leaving the rest (sign and magnitude). Two's complement means invert every bit of the positive value, then add 1.
  • Forgetting to pad a converted number to the register width the question asks for.
  • Mixing bits and bytes in a file-size calculation. Work in bits, divide by 8 once, and say whether you used 1000 or 1024.
  • Answering "describe" in everyday words ("the picture gets worse"). Use the syllabus terms: fewer colours, banding, lower image resolution, larger pixels.

Pelajaran interaktif untuk topik ini

Kerjakan langkah demi langkah, dengan latihan pengecekan instan.

Soal-Soil Masa Lalu

Topik lain dalam Ilmu Komputer A-Level

Masuk atau buat akun

IGCSE, A-Level & AP