L
LLLOS.ai
Learn
L

Chapter 2 — Encodings

Class 11 · Computer Science

Overview

This unit explains how different kinds of information — numbers, text, images, sound and control signals — are represented inside digital systems using binary encodings. You will begin with positional number systems and methods to convert between binary, octal, decimal and hexadecimal. The unit then develops binary arithmetic and several ways to represent signed integers including sign-magnitude, one's complement and two's complement. Fixed-point and IEEE 754 floating-point representations are taught so you learn how fractional and very large or small real numbers are stored and the limits of precision. Character encodings such as ASCII and Unicode show how text from many languages is mapped to bytes. Practical encodings for images, audio and video introduce pixels, colour models, sampling and the reasons for compression. Compression is covered in two parts: lossless techniques (Huffman, LZ) and lossy principles (transform coding, perceptual models). Error control discusses parity, checksums, CRC and simple error-correcting codes (Hamming) and explains trade-offs between detection and correction. Finally, physical-layer line coding and the relationship between baud and bit rate explain how bits become electrical or optical signals. Learning these topics helps you estimate file sizes, avoid numeric precision errors in programs, understand file formats and networking behaviour, and reason about reliability and performance of digital systems — essential for board exams and practical computer science work.

Learning Objectives

  • Describe and convert between binary, octal, decimal and hexadecimal number systems.
  • Perform binary arithmetic and explain overflow, underflow and signed vs unsigned results.
  • Explain and use sign-magnitude, one's complement and two's complement representations for signed integers.
  • Describe fixed-point and IEEE 754 floating-point formats and convert simple numbers into these formats.
  • Explain ASCII and Unicode encodings and convert text characters into numeric codes.
  • Calculate storage requirements for images, audio and video given resolution, sampling rate and bit depth.
  • Explain lossless compression methods such as Huffman and LZ, and describe when to use them.
  • Explain principles of lossy compression and how perceptual models allow high compression ratios.
  • Explain error detection and correction methods and describe common line-coding schemes and their bandwidth implications.

Topics in this chapter

15 topics · tap a topic title to jump straight to it.

💻1

Introduction to Encodings

What is encoding?
Encoding is the process of mapping information from a human-understandable form into binary sequences that computers can store, manipulate and transmit. Everything digital — numbers, letters, pictures and sound — becomes a sequence of bits (0s and 1s). The choice of encoding determines how efficiently and reliably information is handled.

Why encodings matter
Different encodings are chosen depending on goals: compact storage, ease of processing, error resilience, interoperability between systems, or faithful reproduction of data. For example, a simple ASCII encoding is compact for plain English text but cannot represent characters from many world languages; Unicode solves that by using more space when needed. For multimedia, raw formats store every sample but use lots of space; compressed formats reduce size by exploiting redundancy and perceptual limits.

Basic terminology
Bit: the smallest unit of information. Byte: commonly eight bits. Word: the number of bits a machine processes at once (16, 32, 64). Endianness: the order in which bytes are stored for multi-byte values (big-endian vs little-endian). Precision and range: in numeric encodings these determine what values can be represented exactly and which cannot.

Where encodings are used
Encodings are used in file formats (text files, images, audio files), communication protocols (how bits are sent over wires), and internal computer arithmetic. Operating systems and programming languages provide libraries to convert among encodings because mismatches cause garbled text or wrong numerical results.

How we will study this unit
Start with number systems (how bases work and conversions), then learn binary arithmetic and signed integer representations. Next cover fixed-point and floating-point for real numbers, then character encodings (ASCII, Unicode). Move on to media: images, audio and video, including how to compute storage needs and why compression is used. Finally study error detection/correction and line coding for transmission. Each topic includes examples and calculations so you can reason about file sizes, precision, and errors in practical settings.

Practical skills you will gain
By the end of the unit you should be able to convert numbers between bases, represent integers and real numbers in computer formats, estimate sizes of files and choose suitable encodings, and understand basic error-control and physical-layer signalling methods. These skills are useful in programming, debugging, and understanding how digital devices handle information.

📌 Examples
  • Example: The string "OK" in ASCII is two bytes: 'O' = 0x4F and 'K' = 0x4B so stored as 4F 4B in hex.
  • Example: A 100×100 grayscale image with 8 bits per pixel uses 100×100×1 = 10,000 bytes of storage if uncompressed.
🧮 Formulas
  1. 1 byte = 8 bits
  2. Uncompressed image size (bytes) = width × height × bits_per_pixel / 8
📊 Visual ideas
Diagram of bits grouped into a byte and bytes into a 32-bit word showing indexing of bits.
Illustration of big-endian vs little-endian for a 32-bit integer showing memory addresses and byte order.
🔢2

Number Systems: Binary, Octal, Decimal, Hexadecimal

Place-value notation
All positional number systems use digits placed in positions that represent increasing powers of the base (radix). In base b, the rightmost digit represents b^0, the next b^1, then b^2, and so on. Decimal (base 10) uses digits 0–9; binary (base 2) uses 0 and 1; octal (base 8) uses 0–7; hexadecimal (base 16) uses 0–9 and A–F (for values 10–15).

Converting integers from decimal to another base
To convert a decimal integer to base b, perform repeated division by b. At each step divide the number by b, write down the remainder; then divide the quotient again. Continue until quotient is zero. The base-b representation is the sequence of remainders read from last to first. This method works for any base.

Converting integers from other bases to decimal
To convert a number given in base b to decimal, multiply each digit by b raised to the position index and add them. For example, in base 16 the number 3A5 equals 3×16^2 + 10×16 + 5.

Binary grouping shortcuts
Binary is closely related to octal and hexadecimal because powers of two match their bases: 2^3 = 8 and 2^4 = 16. Group binary digits in threes to convert to octal and in fours to convert to hexadecimal. This makes conversions quick: e.g., binary 110101 → group as 110 101 → octal digits 6 and 5 → 65₈.

Fractional parts
To convert fractional decimal numbers to base b, repeatedly multiply the fractional part by b. The integer parts produced at each multiplication become the digits after the radix point. For converting fractional parts from base b to decimal, multiply each digit by b^{−n} where n is position after the point and sum. Many fractions terminate in some bases and recur in others; for instance 0.5 decimal is 0.1 in binary, but 0.1 decimal is recurring in binary.

Signed numbers and representations
While conversions above apply to unsigned magnitudes, signed numbers require a representation scheme (discussed in later topics). When converting negative numbers in two's complement, it is common to convert the absolute value and then apply the two's complement procedure.

Practical tips
Use hexadecimal to represent bytes because one hex digit covers four bits and two hex digits represent a byte. Programmers often use hex constants (0x...) for readability. For manual work, write out powers of the base and align digits carefully to avoid mistakes. Always check by converting back to decimal.

📌 Examples
  • Convert decimal 156 to binary: 156/2 → remainders 0,0,1,1,1,0,0,1 reading reverse gives 10011100₂.
  • Convert binary 110101.101 to decimal: integer 110101₂ = 53; fractional .101₂ = 0.5 + 0 + 0.125 = 0.625; total = 53.625₁₀.
🧮 Formulas
  1. \[Value (base b) = Σ (digit × b^{position}) for integer part\]
  2. \[Fraction value = Σ (digit × b^{−n}) for digits after the radix point\]
📊 Visual ideas
Place-value chart showing positions for base 2, base 10 and base 16 with powers and example digits.
Step-by-step tree showing repeated division for converting 45₁₀ to binary with remainders at each step.
3

Binary Arithmetic: Addition, Subtraction, Multiplication, Division

Binary addition rules
Binary arithmetic follows place-value rules with base 2. The basic addition truths are: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (which is 0 with a carry of 1). If three bits are added (including a carry-in), 1+1+1 = 11 (which is 1 with a carry of 1). When adding multi-bit numbers, work from least significant bit (rightmost) to most significant, propagating carries. In fixed n-bit registers, a final carry out may indicate overflow for unsigned arithmetic.

Detecting overflow
Overflow depends on whether the operands are signed or unsigned. For unsigned n-bit addition, overflow occurs if there is a carry out of the most significant bit (MSB). For signed two's complement numbers, overflow occurs when two operands of the same sign produce a result with a different sign; equivalently, when the carry into MSB differs from carry out of MSB.

Binary subtraction
Subtraction A − B can be done by complementing B and adding: in two's complement systems take two's complement of B (invert bits and add 1) and compute A + (−B). This simplifies hardware because one adder can perform both addition and subtraction. Alternatively, perform borrow-based column subtraction similar to decimal subtraction.

Multiplication
Binary multiplication uses shifting and addition. Multiply the multiplicand by each bit of the multiplier (0 gives zeros, 1 gives the multiplicand) and shift the partial product left appropriate positions before summing. This is analogous to long multiplication in decimal. In hardware, Booth's algorithm and other optimisations reduce the number of additions.

Division
Binary division is repeated subtraction and shifting. The algorithm shifts the divisor and subtracts from the dividend, setting quotient bits when subtraction succeeds. Modern CPUs use restoring or non-restoring division algorithms to implement division in hardware efficiently.

Fixed-width arithmetic concerns
In fixed n-bit arithmetic, results wrap modulo 2^n. For unsigned numbers this behaviour is straightforward but may be undesirable if overflow is unhandled. For fixed-point arithmetic, scaling must be managed so fractional positions remain aligned. Always check bit width and signedness in numerical computations to avoid silent errors.

Practical advice
When adding or multiplying large numbers by hand, write carries clearly. Use two's complement for signed arithmetic to avoid handling signs separately. In programming, use data types with sufficient bit width and, for critical calculations, consider using arbitrary-precision libraries or floating-point if needed.

📌 Examples
  • Add 1011₂ + 1101₂: 1+1=10 carry1; continue to obtain 11000₂. Show carries at each column when performing by hand.
  • Multiply 101₂ by 11₂: partial products are 101 and 101 shifted giving 101 + 1010 = 1111₂.
🧮 Formulas
  1. Unsigned range for n bits: 0 to 2^n − 1
  2. Two's complement arithmetic wraps modulo 2^n
📊 Visual ideas
Column layout for binary addition of 1011 and 1101 showing carries per column.
Long multiplication showing shifted partial products for 101 × 11.
4

Signed Integer Representations (Sign-Magnitude, One's Complement, Two's Complement)

Need for signed representations
Unsigned binary can only represent non-negative values. To represent negative integers we use signed encodings which reserve some information to indicate sign and magnitude. Each method has trade-offs in simplicity, arithmetic behaviour, and representable range.

Sign-magnitude
Sign-magnitude uses the most significant bit (MSB) as a sign bit: 0 for positive and 1 for negative. The remaining bits store the magnitude using standard binary. For an n-bit word, magnitude uses n−1 bits so range is −(2^{n−1} − 1) to +(2^{n−1} − 1) with two representations of zero (+0 and −0). Arithmetic must treat sign bits separately, complicating hardware.

One's complement
One's complement represents negative numbers by inverting all bits of the positive representation (bitwise NOT). Example in 8 bits: +5 = 00000101; −5 = 11111010. One's complement still has two zeros (all zeros and all ones) and requires an end-around carry when adding: if there is a carry out of MSB, add it back into LSB. This makes hardware simpler than sign-magnitude but still imperfect.

Two's complement
Two's complement forms negative numbers by inverting bits and adding one. It eliminates the double-zero problem and unifies addition/subtraction using the same adder hardware. For n bits, two's complement range is −2^{n−1} to 2^{n−1} − 1, asymmetric because the most negative value has no positive counterpart. Sign extension is simple: when increasing bit width, replicate the sign bit into new bits to preserve value.

Arithmetic consequences and overflow
Two's complement arithmetic wraps modulo 2^n. Overflow detection differs for signed numbers: overflow occurs when adding two numbers with the same sign yields a result with a different sign (or equivalently when carries into and out of MSB differ). One's complement and sign-magnitude require extra logic to handle signs in arithmetic operations, making two's complement the standard in modern systems.

Choosing a representation
For teaching and clarity, sign-magnitude shows the concept of sign plainly; one's complement introduces the idea of bit inversion; two's complement is used in practice due to arithmetic convenience. Understanding all three helps when reading older documentation or particular protocol specifications that might use non-standard encodings.

Examples and conversions
To convert negative numbers: sign-magnitude simply set MSB; one's complement invert bits; two's complement invert and add one. To interpret a two's complement bit pattern, if MSB is 0 treat as positive; if MSB is 1, compute two's complement to get magnitude and add a negative sign.

📌 Examples
  • Sign-magnitude in 6 bits: +18 = 010010, −18 = 110010.
  • One's complement example in 8 bits: +7 = 00000111, −7 = 11111000.
  • Two's complement example: +12 = 00001100 → −12 = invert 11110011 → add 1 → 11110100.
🧮 Formulas
  1. Two's complement negative value = (2^n) − magnitude for an n-bit pattern interpreted unsigned
  2. \[Signed two's complement range for n bits: −2^{n−1} to 2^{n−1} − 1\]
📊 Visual ideas
Table of bit patterns for numbers −3 to +3 in sign-magnitude, one's complement and two's complement for comparison.
Illustration showing invert-and-add-1 steps to produce two's complement negative of a positive binary number.
💻5

Fixed-Point Representation

What fixed-point means
Fixed-point representation stores real numbers by fixing the location of the binary (or decimal) point. A fixed number of bits represent the integer part and a fixed number represent the fractional part. This contrasts with floating-point where the position of the point can change via an exponent.

Format notation and interpretation
Commonly used notation is Qm.f where m is number of bits for integer part (including sign if signed) and f is number of bits for fractional part. A stored integer value V in Qm.f format represents the real number V × 2^{−f}. For example, a Q7.8 value stored as 00000001 00000000 (binary) represents 1.0 because integer stored = 256 so 256×2^{−8} = 1.

Range and precision
The number of fractional bits f determines resolution: the smallest representable step (LSB) is 2^{−f}. The integer bits determine range. For signed fixed-point using two's complement, the total number of bits n = m + f and range is approximately −2^{m−1} to 2^{m−1} − 2^{−f}. Fixed-point gives predictable precision and fast arithmetic on hardware without floating-point units, but limited dynamic range.

Arithmetic operations
Addition and subtraction require operands to share the same Q format. Multiplication of two Qm.f numbers results in Q(2m).(2f) if not rescaled; to restore the original scale shift the product right by f bits (effectively divide by 2^f). Division requires left-shifting the dividend before integer division or using other rescaling methods to preserve fractional precision. Proper rounding may be applied after shifting to reduce cumulative errors.

Advantages and disadvantages
Advantages: speed, deterministic behaviour and simplicity in embedded systems. Disadvantages: limited range and careful scaling needed to avoid overflow or loss of precision. Fixed-point is widely used in digital signal processing (audio codecs, filters) and microcontrollers without FPU.

Implementational notes
When converting between fixed-point formats, align fractional bits by shifting left or right. When increasing fractional bits to gain precision, keep in mind sign extension for signed values. Always check for overflow after arithmetic and apply saturation or wrap-aware logic as required by application.

📌 Examples
  • Q4.4 example: binary 0010.1000 represents 2 + 8/16 = 2.5.
  • Multiplication example: multiply Q3.5 numbers then shift right by 5 bits to restore Q3.5 format and possibly round.
🧮 Formulas
  1. \[Value = stored_integer × 2^{−f} for Qm.f format\]
  2. After multiplication: rescale by shifting right by f bits (divide by 2^f)
📊 Visual ideas
Bit layout diagram showing sign bit, integer bits and fractional bits for Q7.8 format with example value.
Flow diagram of multiplication in fixed-point showing operand multiplication → raw product → rescale (shift) → round/truncate.
🛟6

Floating-Point Representation and IEEE 754

Why floating-point is used
Floating-point representation allows storage of very large and very small real numbers with a limited number of bits by splitting a number into a significand (mantissa) and an exponent. This is similar to scientific notation; it gives a trade-off between dynamic range and precision and is used for most general-purpose real-number computations.

IEEE 754 standard
IEEE 754 defines formats and arithmetic rules for floating-point numbers. Common formats are single precision (32-bit) and double precision (64-bit). A single-precision number has 1 sign bit, 8 exponent bits and 23 fraction bits. The stored value is interpreted as (−1)^{S} × (1.F) × 2^{E − bias} for normalized numbers, where bias = 127 for single precision. Double precision uses 1 sign, 11 exponent, 52 fraction bits and bias 1023.

Normalized, denormalized and special values
Normalized numbers assume an implicit leading 1 in the significand (the hidden bit) which gives extra precision. If exponent bits are all zeros and fraction non-zero, the number is denormalized (subnormal), represented as (−1)^{S} × (0.F) × 2^{1 − bias}; denormals fill the gap near zero with reduced precision. If exponent bits are all ones and fraction is zero, the value is ±infinity; if fraction is non-zero, the value is NaN (Not a Number), used for invalid results like 0/0.

Precision and machine epsilon
Floating-point cannot represent all real numbers exactly; results are rounded to nearest representable value according to rounding mode (default round to nearest even). Machine epsilon is the difference between 1 and the next representable floating-point number; it measures precision. Numerical algorithms must account for rounding errors, cancellation (loss of significant digits when subtracting close numbers), and accumulation of errors in loops.

Converting numbers
To convert a decimal number to IEEE 754 single precision: (1) convert to binary, (2) normalize to 1.F × 2^E, (3) compute exponent field as E + bias, (4) fill fraction bits from F rounding as needed, and (5) set sign bit. Understanding normalization and exponent bias is important for correct manual conversions.

Practical implications
Floating-point operations are fast on hardware with FPU but still approximate. For high-precision needs use double precision or arbitrary-precision libraries; for predictable fixed decimal digits (money) prefer fixed-point or decimal types. Know special values and how comparisons behave (NaN comparisons are special). Many subtle bugs in programs come from misunderstanding floating-point behaviour rather than language syntax.

📌 Examples
  • Single precision example: 6.5 = 110.1₂ = 1.101 × 2^2 ⇒ sign 0, exponent = 2+127=129 (10000001₂), fraction begins 101000...0.
  • Special case: exponent all ones with zero fraction → ±infinity; all ones with non-zero fraction → NaN.
🧮 Formulas
  1. \[Value = (−1)^{S} × (1.F) × 2^{E − bias}\]
  2. Bias: single precision = 127; double precision = 1023
📊 Visual ideas
Bit-field diagram for IEEE 754 single precision showing [sign][exponent][fraction] widths and example bits.
Diagram illustrating spacing of representable numbers near 1 and near large magnitudes, and showing denormal numbers near zero.
💻7

Character Encoding: ASCII and Unicode

Purpose of character encodings
Text must be represented as numbers for storage and processing. Character encodings map characters (letters, digits, punctuation and control signals) to numeric code points, which are then stored as binary. Choices of encoding affect language support, file size and compatibility.

ASCII basics
ASCII uses 7 bits to encode 128 characters: control codes (0–31), printable characters (32–126) and DEL (127). Common printable characters include digits '0'–'9', uppercase 'A'–'Z' and lowercase 'a'–'z'. Because ASCII fits in one byte with MSB zero, many systems store ASCII in 8-bit bytes for convenience. ASCII includes control codes like LF (line feed, 10) and CR (carriage return, 13) used in text formatting and communications.

Limitations of ASCII
ASCII only covers basic Latin script and lacks accented characters, diacritics and characters of most world languages. This limitation led to numerous incompatible extensions in the past, causing problems when text moved between systems using different code pages.

Unicode and UTF encodings
Unicode assigns a unique code point to nearly every character used in human writing systems, symbols and emoji. Code points are written U+xxxx. Unicode itself is an abstract mapping of characters to numbers; actual bytes are produced by encodings called UTFs. UTF-8 is variable-length and backward-compatible with ASCII: U+0000 to U+007F use one byte identical to ASCII; other code points use 2–4 bytes. UTF-16 uses 16-bit units and may need surrogate pairs for code points beyond U+FFFF. UTF-32 uses 4 bytes per code point, simple but space-inefficient. UTF-8 is most common on the web due to compactness for Latin scripts and robustness.

Practical aspects
Files must declare or assume an encoding; misinterpreting encoding leads to garbled text. Many protocols use byte-order markers (BOM) for UTF-16/32 to indicate endianness. Be careful when counting characters: number of bytes ≠ number of characters in UTF-8 since characters may be multi-byte. Libraries in programming languages provide functions to encode/decode Unicode strings; understand when to use them to avoid bugs.

Normalization and comparability
Unicode includes composed and decomposed forms (e.g., 'é' can be a single code point or 'e' + combining accent). Unicode normalization forms (NFC, NFD) ensure comparable representations for string matching and storage.

📌 Examples
  • ASCII examples: 'A' = 65 (01000001₂), 'a' = 97 (01100001₂), '0' = 48 (00110000₂).
  • UTF-8 example: U+20AC (Euro sign) encodes as three bytes E2 82 AC; ASCII text 'Hello' is same bytes in UTF-8 and ASCII.
🧮 Formulas
  1. ASCII uses 7 bits → 2^7 = 128 characters
  2. UTF-8 lengths: 1 byte for U+0000–U+007F, 2 bytes for U+0080–U+07FF, 3 bytes for U+0800–U+FFFF, 4 bytes for U+10000–U+10FFFF
📊 Visual ideas
Table showing ASCII codes for digits (48–57), uppercase letters (65–90) and lowercase letters (97–122).
Diagram comparing UTF-8 (variable bytes) and UTF-32 (fixed 4 bytes) for same string showing bytes used.
💻8

Representing Images and Image Compression

Pixels and bitmaps
Digital images are arrays of pixels arranged in rows and columns. Each pixel stores colour information. A bitmap stores the colour of every pixel explicitly; resolution is width × height. Bit depth indicates how many bits describe each pixel: 1-bit for black-and-white, 8-bit for 256 indexed colours, and 24-bit true colour with 8 bits per RGB channel allowing over 16 million colours.

Colour models
Most displays use RGB colour model: each pixel has red, green and blue intensity channels. Other models like YUV split luminance (Y) and chrominance (U, V) components; YUV is commonly used in video because human vision is more sensitive to luminance details than chroma, allowing chroma subsampling (e.g., 4:2:0) to reduce data with little visible loss.

Storage size calculation
Uncompressed image size in bytes = width × height × bits_per_pixel / 8. For example, a 1024×768 image at 24 bpp uses 1024×768×3 = 2,359,296 bytes (~2.25 MB) not counting headers.

Palettes and indexed colour
When images use few colours, a palette (colour lookup table) maps small pixel indices to full colours. An 8-bit indexed image stores one byte per pixel indexing a table of up to 256 colours; this reduces size when used appropriately (icons, GIFs).

Lossless compression methods for images
Lossless image compression exploits redundancy: Run-Length Encoding (RLE) compresses runs of identical pixels (useful for simple graphics), while dictionary methods (LZ77 family) replace repeated patterns with references. PNG uses a combination of filtering, LZ-like compression (DEFLATE) and Huffman coding to compress images without quality loss.

Lossy compression and JPEG
Photographic images benefit from lossy compression like JPEG. JPEG divides image into blocks, applies the Discrete Cosine Transform (DCT) to each block, quantizes the transform coefficients (discarding small coefficients that contribute little to perceived image), and entropy-encodes the result. Lossy compression introduces artifacts (blocking, blurring) at high compression but achieves large size reduction.

Choosing formats
Use lossless formats (PNG) for line art, text, and images requiring exact reproduction; use lossy (JPEG, modern alternatives like WebP/HEIF) for photographs and web images where smaller size matters. Newer formats improve compression efficiency and often provide both lossless and lossy modes.

📌 Examples
  • Calculate bytes for 800×600 24-bit image: 800×600×3 = 1,440,000 bytes ≈ 1.44 MB.
  • RLE example: pixel row A A A A B B B C C encoded as (A4)(B3)(C2) to save space when many repeats exist.
🧮 Formulas
  1. Image size (bytes) = width × height × bits_per_pixel / 8
  2. Compression ratio = uncompressed_size / compressed_size
📊 Visual ideas
Grid diagram of pixels forming an image with an example pixel showing its RGB channels.
Block diagram of JPEG pipeline: block → DCT → quantization → zig-zag → entropy coding.
💻9

Audio Encoding: Sampling, PCM and Compression

From analogue to digital
Sound is a continuous-time waveform. To represent it digitally we sample the waveform at discrete time intervals and quantize each sample's amplitude into a finite number of levels. The most common uncompressed digital format is PCM (Pulse Code Modulation) which stores the sequence of amplitude samples as binary numbers.

Sampling theorem and sampling rate
The Nyquist–Shannon sampling theorem states that to reconstruct a band-limited signal perfectly, the sampling rate must be greater than twice the highest frequency present in the signal. Human hearing typically ranges to about 20 kHz, so CD-quality audio uses 44.1 kHz sampling. Lower sampling rates reduce fidelity and may cause aliasing if proper anti-alias filters are not used.

Bit depth and dynamic range
Bit depth (bits per sample) determines amplitude resolution. A 16-bit sample provides 2^{16} = 65,536 discrete levels and about 96 dB of dynamic range, whereas 24-bit increases dynamic range further. Stereo audio stores two channels (left and right). File size for PCM = sampling_rate × bits_per_sample × channels × duration_seconds / 8.

Quantization and noise
Quantization maps continuous amplitudes to discrete levels; the difference is quantization error (noise). Higher bit depth reduces this error. Dithering (adding low-level noise before quantization) can reduce audible quantization distortion by decorrelating quantization errors.

Compression of audio
Uncompressed PCM files are large. Lossless audio formats such as FLAC compress without loss by removing redundancy. Lossy formats like MP3 and AAC use perceptual models (psychoacoustics) to discard sounds that are masked by louder frequencies or are less perceptible, achieving much higher compression ratios. For archival or editing use lossless; for distribution and streaming lossy formats are common due to smaller size.

Practical calculations
Example: 44.1 kHz, 16-bit, stereo, 3 minutes → size = 44100 × 16 × 2 × 180 / 8 ≈ 30 MB. For 22.05 kHz mono 16-bit, 2 minutes → size ≈ 5.29 MB (calculate similarly). These calculations help plan storage and bandwidth requirements.

📌 Examples
  • Size calculation: 44.1 kHz × 16-bit × stereo × 180 s / 8 = ~30 MB for 3 minutes of CD-quality audio.
  • Quantization example: 8-bit audio with 256 levels can show audible step-like distortion in quiet passages compared to 16-bit.
🧮 Formulas
  1. Audio size (bytes) = sampling_rate × bits_per_sample × channels × duration_seconds / 8
  2. Nyquist sampling requirement: sampling_rate > 2 × highest_frequency
📊 Visual ideas
Graph showing an analogue waveform and discrete sampled points with quantization levels illustrated.
Bar chart comparing sizes of PCM, FLAC (lossless) and MP3 (lossy) for same audio clip.
💻10

Video Encoding Basics

Video as a sequence of images
Video is a time sequence of frames displayed at a certain frame rate (e.g., 24, 25, 30 or 60 frames per second). Each frame is an image; therefore uncompressed video data grows quickly and needs compression for practical storage and transmission.

Spatial and temporal redundancy
Video codecs exploit both spatial redundancy within frames (like image compression) and temporal redundancy between frames. Temporal redundancy is reduced using inter-frame prediction: keyframes (I-frames) store full image data, while predicted frames (P-frames) store differences from previous frames and bidirectionally predicted frames (B-frames) use both past and future frames to predict content. This approach reduces bitrate significantly for typical footage where consecutive frames are similar.

Colour spaces and chroma subsampling
Video commonly uses a luminance-chrominance model (YUV or YCbCr) separating brightness (Y) from colour (U and V channels). Because human vision is more sensitive to luminance than chrominance details, chroma subsampling (e.g., 4:2:2, 4:2:0) reduces colour resolution to save bandwidth with minor perceived loss.

Compression transforms and motion compensation
Modern codecs (H.264, H.265, VP9, AV1) use block-based transforms (like DCT or integer approximations), quantization and entropy coding (CABAC/CAVLC) combined with motion estimation/compensation. Motion vectors describe how blocks moved between frames; residuals (differences) are then transformed and quantized, leveraging human perception to discard less-important details.

Containers and codecs
Containers (MP4, MKV) package video, audio and metadata but do not define compression. Codecs (encoders/decoders) define how data is compressed. Choose a codec for compatibility and efficiency; newer codecs provide better compression at higher decoding complexity.

Bandwidth and storage calculations
Uncompressed video size (bytes/sec) = width × height × bytes_per_pixel × frames_per_second. For example, 1920×1080 at 24 fps uncompressed 8-bit RGB is roughly 149 MB/s, so compression is essential. Bitrate targets and GOP (group of pictures) structure influence quality and size.

📌 Examples
  • Calculating uncompressed size: 1920×1080, 24 fps, 3 bytes/pixel → 1920×1080×3×24 ≈ 149 MB/s uncompressed.
  • Chroma subsampling 4:2:0 reduces chroma data to one quarter of luma samples per block, saving significant bandwidth.
🧮 Formulas
  1. Uncompressed video bytes/sec = width × height × bytes_per_pixel × frames_per_second
  2. Chroma subsampling 4:2:0 reduces chroma samples horizontally and vertically by factor 2 each
📊 Visual ideas
Timeline diagram showing I, P and B frames and motion vectors pointing to reference frames.
Diagram comparing full RGB sampling vs YUV 4:2:0 chroma subsampling for a 2×2 block showing which samples are stored.
📊11

Lossless Data Compression: Huffman, LZ and Practical Schemes

Goal of lossless compression
Lossless compression reduces data size without losing any information. It is required when exact reconstruction is necessary: text files, program code, some images and scientific data. Lossless methods exploit statistical redundancy or repeated patterns in the data.

Statistical coding: Huffman
Huffman coding assigns variable-length prefix-free codes to symbols based on their frequencies: common symbols get short codes and rare ones get long codes. Build a binary tree by repeatedly merging the two least-frequent nodes; the code for each symbol is the path from root to leaf. Huffman coding is optimal for symbol-by-symbol coding given known frequencies and forms a core part of many compressors.

Dictionary methods: LZ family
Dictionary methods (LZ77, LZ78) replace repeated strings with references to earlier occurrences. LZ77 uses a sliding window: when a match is found in the window, the encoder outputs a pointer (distance, length) to the previous occurrence. LZ78 builds an explicit dictionary of phrases. Practical compressors (DEFLATE used by ZIP/PNG) combine LZ77 with Huffman coding to represent literals and pointers compactly.

Entropy and limits
Entropy H = −Σ p(i) log2 p(i) measures the minimum average number of bits per symbol required by any lossless coding scheme. No lossless compressor can always produce code lengths below entropy for arbitrary data. The effectiveness depends on redundancy in the specific data.

Practical considerations
Compression ratio depends on data type: text and structured data compress well; already compressed or random data compress poorly. Memory and CPU constraints influence algorithm choice: LZ77 with Huffman is good for general use; more powerful compressors (bzip2, LZMA) trade CPU and memory for better compression. Streaming systems use smaller windows to allow on-the-fly processing.

Use cases and file formats
PNG uses DEFLATE (LZ77 + Huffman) for lossless images; ZIP and gzip use similar approaches. Understanding how these methods work helps troubleshoot file sizes and choose appropriate settings for backup and transmission.

📌 Examples
  • Huffman example: for symbols with frequencies A(45), B(13), C(12), D(16), E(9), F(5), build a tree to assign shortest code to A.
  • LZ77 example: data 'ABCABCABC' can be encoded as 'ABC' then references to previous 'ABC' occurrences with distance and length instead of repeating.
🧮 Formulas
  1. Entropy H = − Σ p(i) log2 p(i)
  2. Average code length ≥ H (Shannon's source coding theorem)
📊 Visual ideas
Huffman tree diagram showing symbol leaves with codewords derived from tree paths.
Sliding window illustration for LZ77 with lookahead buffer and match pointer encoding.
💻12

Lossy Compression Principles

Why lossy compression
Lossy compression achieves higher compression ratios by discarding information judged least important for perception. It is used for images, audio and video where perfect reconstruction is not necessary. The design relies on human visual and auditory models to hide losses while keeping the content acceptable.

Transform coding
Most lossy image and video codecs use transform coding. Images are divided into blocks and a transform (such as the Discrete Cosine Transform, DCT) converts spatial samples into frequency coefficients. Energy often concentrates in a few low-frequency coefficients. Quantization reduces precision of high-frequency coefficients more than low-frequency ones because humans are less sensitive to fine details. After quantization, remaining coefficients are entropy-coded.

Perceptual models in audio
Audio codecs use psychoacoustic models: they identify frequencies that are masked by louder sounds and remove them, or reduce precision where errors are not audible. Temporal masking and frequency masking allow codecs like MP3 and AAC to remove inaudible components and achieve significant compression.

Rate–distortion trade-off
Compression involves choosing a point on the rate–distortion curve: lower bitrate (rate) means higher distortion. Encoder settings (quality level, quantization parameters, target bitrate) control this balance. There is a knee region where small increases in bitrate yield large improvement in quality; beyond that returns diminish.

Artifacts and practical limits
Excessive compression introduces artifacts: blocking and ringing in JPEG images, pre-echo or warbling in audio, and macroblocking or blurring in video. Choosing appropriate parameters and modern codecs reduces visible artifacts. For editing and archival tasks avoid lossy transforms to prevent cumulative degradation.

Modern codecs and improvements
New codecs (HEVC/H.265, AV1, newer image formats like WebP and HEIF) use better transforms, adaptive quantization and advanced prediction to improve compression efficiency. However, decoding complexity and patent/licensing issues are practical constraints. When designing systems, decide whether lossy compression is acceptable, and choose codecs matching quality, latency and licensing needs.

📌 Examples
  • JPEG pipeline: divide into 8×8 blocks, apply DCT, quantize coefficients (larger quantization for high frequencies), zig-zag scan then entropy code.
  • MP3 example: masked frequencies removed according to psychoacoustic model, leaving perceptually important components to be encoded.
🧮 Formulas
  1. Compression trade-off: aim to minimize distortion D for a given bitrate R, commonly considered in rate–distortion theory.
  2. Compression ratio = original_size / compressed_size
📊 Visual ideas
Rate–distortion curve showing diminishing returns and knee point indicating efficient operating region.
Visual comparison showing an original image and a heavily compressed JPEG with blocking artifacts.
💻13

Error Detection and Correction (Parity, Checksums, CRC, Hamming)

Need for error control
Bits can be corrupted during storage or transmission due to noise, interference or hardware faults. Error control schemes add redundancy so receivers can detect and possibly correct errors, allowing reliable communication and storage without undetectable corruption.

Parity bits
Parity is the simplest detection method: append a bit so total number of 1s in a block is even (even parity) or odd (odd parity). Parity detects any odd number of bit errors but fails for even-numbered bit flips. It is cheap and used for simple link-level error detection where the error environment is mild.

Checksums
Checksums compute a sum of data words (commonly modulo 2^n) and append the result. They detect many common errors like single-bit flips and some multi-bit errors, but carefully crafted changes can cancel out and escape detection. Checksums are used in transport protocols and file formats for quick integrity checks.

Cyclic Redundancy Check (CRC)
CRC treats bit sequences as polynomials over GF(2) and computes a remainder when dividing by a chosen generator polynomial. The transmitter appends this remainder; the receiver recomputes the remainder and if non-zero detects an error. Well-chosen CRC polynomials detect single-bit errors, double-bit errors, and burst errors up to certain lengths. CRCs are efficient in hardware using shift registers and XOR gates and are widely used in networking and storage.

Error correction: Hamming and FEC
Error correction adds more redundancy so some errors can be corrected without retransmission. Hamming codes are simple block codes capable of detecting and correcting single-bit errors and detecting some double-bit errors; they place parity bits at positions that are powers of two and compute parity checks whose pattern (syndrome) pinpoints the erroneous bit. More powerful forward error correction (FEC) codes — Reed–Solomon, convolutional codes, LDPC and Turbo codes — can correct multiple errors and are used in CDs, DVDs, mobile and satellite communications.

Trade-offs and system design
Error detection is cheaper but requires retransmission on failure (ARQ). FEC reduces retransmission but increases bandwidth or storage due to extra redundancy. System designers choose methods based on channel error characteristics, latency tolerance and resource constraints.

📌 Examples
  • Parity example: data 1011001 has four ones (even); even parity bit is 0 to keep total ones even; if one bit flips, parity fails.
  • Hamming (7,4) example: 4 data bits produce 3 parity bits placed at positions 1,2,4; a single-bit error produces a non-zero syndrome which indicates the erroneous bit position.
🧮 Formulas
  1. Simple checksum = Σ data_words mod 2^n
  2. Hamming relation: for r parity bits and k data bits, 2^r ≥ k + r + 1
📊 Visual ideas
Block diagram of CRC transmitter showing data appended with r zeros, division by generator polynomial and remainder appended.
Layout of Hamming (7,4) positions showing which parity bits check which data bits and how syndrome indicates error position.
💻14

Line Coding and Physical Transmission (NRZ, Manchester, Baud vs Bit Rate)

From bits to signals
Line coding converts sequences of bits into electrical or optical signals suitable for the transmission medium. The choice of line code affects synchronization, DC content, spectral properties (bandwidth), and susceptibility to noise. Good line coding helps receivers recover clock timing and data reliably.

NRZ (Non-Return-to-Zero)
NRZ maps logical 1 to one signal level and logical 0 to another, without returning to a neutral level between bits. It is simple and bandwidth-efficient but suffers from long runs of identical bits causing baseline wander and loss of clock recovery because there may be no transitions to lock onto.

Manchester encoding
Manchester encoding combines clock and data by using transitions in the middle of each bit period. One convention uses high-to-low as 0 and low-to-high as 1 (or vice versa depending on standard). Because every bit has a transition, Manchester simplifies clock recovery and has no DC component, but it uses roughly twice the bandwidth compared to NRZ for the same data rate because the effective fundamental frequency is doubled.

Multi-level signalling and baud vs bit rate
Baud is the number of signal symbols transmitted per second. Bit rate is the number of information bits transmitted per second. If each symbol encodes multiple bits (multi-level signalling such as M-ary PAM or QAM), then bit rate = baud × bits_per_symbol. For binary signalling bits_per_symbol = 1 so baud equals bit rate. Modern modems increase bits_per_symbol to achieve higher bit rates in limited bandwidth by using amplitude and phase modulation.

Trade-offs and channel considerations
Line coding affects spectral occupancy and susceptibility to channel impairments. Manchester is robust for clock recovery but consumes more bandwidth; NRZ is compact but needs additional protocols for clocking and DC compensation. Practical systems combine line coding with higher-layer framing, error control and equalization to achieve reliable data transfer over the physical medium.

Examples and calculations
If a link uses Manchester encoding at a data bit rate of 1 Mbps, the required bandwidth is roughly double that of NRZ for the same bit rate, i.e., approximately 2 MHz of fundamental frequency. If a modem transmits 2400 baud with 4 bits per symbol, the bit rate is 2400 × 4 = 9600 bits/s.

📌 Examples
  • Manchester example: bit sequence 1100 encoded with transitions in the middle of each bit cell ensuring frequent edges for clock recovery.
  • Baud vs bits example: 2400 baud with 4 bits/symbol → 9600 bits/s.
🧮 Formulas
  1. Bit rate = baud × bits_per_symbol
  2. For binary signalling bits_per_symbol = 1 so baud = bit rate
📊 Visual ideas
Timing diagram showing NRZ and Manchester encodings for the same bit sequence, marking transitions and bit periods.
Illustration of four-level signalling with symbol mapping to two bits per symbol.
💻15

Practical Calculations and Examples

Why practical calculations matter
Understanding how to compute sizes, perform conversions and measure precision helps you design and debug systems, choose formats and answer exam questions. This topic collects common calculation patterns that appear repeatedly across encodings.

File size calculations
For uncompressed data, multiply counts by size per item: image bytes = width × height × bits_per_pixel / 8. Audio bytes = sampling_rate × bits_per_sample × channels × duration_seconds / 8. Video bytes/second = width × height × bytes_per_pixel × frames_per_second. For storage estimates include headers and metadata: add a small overhead percentage (commonly 1–5%) if exact format headers are unknown.

Converting representations
Follow step-by-step procedures: to convert decimal to binary use repeated division; to convert binary fraction to decimal multiply by powers of two; to form two's complement invert bits and add one; to form IEEE 754 single precision convert to binary, normalize, compute biased exponent and fill fraction bits then round. Always verify by converting back to decimal.

Precision and rounding examples
Floating-point rounding can cause surprising results: (0.1)₁₀ cannot be represented exactly in binary floating-point and accumulates error when summed many times. Machine epsilon for IEEE 754 single is about 1.19×10^{−7}; comparing floats for equality is unsafe—use tolerances.

Error-control practicalities
To detect errors choose CRC of appropriate degree based on expected burst length; small embedded links can use parity; file checksums (e.g., SHA or MD5) detect accidental corruption but are not substitutes for CRC in streaming hardware because of performance differences.

Worked examples checklist
When solving exam/assignment problems: write base assumptions (signed/unsigned, bit width), show intermediate steps (division remainders, carries, inversion and addition for two's complement, normalization for floating point), and check results by reverse conversion or range checks. State units (bytes, bits, MB) clearly and use powers of 1024 vs 1000 appropriately when required by question context.

Summary
Practical calculation skills connect theoretical encoding knowledge to real systems and exam questions. Practice converting, calculating sizes and analysing precision issues to build confidence and avoid common mistakes in programming and data handling.

📌 Examples
  • Calculate storage for 22.05 kHz, 16-bit, mono, 2 minutes: 22,050 × 16 × 1 × 120 / 8 = 5,292,000 bytes ≈ 5.29 MB.
  • Convert hex 3A5 to decimal: 3×16^2 + 10×16 + 5 = 933.
🧮 Formulas
  1. Image size (bytes) = width × height × bits_per_pixel / 8
  2. Audio size (bytes) = sampling_rate × bits_per_sample × channels × duration_seconds / 8
📊 Visual ideas
Checklist flow: read problem → note formats and widths → convert inputs → compute sizes or encodings → verify by reverse conversion.
Example layout showing steps to convert decimal 237 to binary using repeated division with remainders.

Key Concepts

Bit
A binary digit, the smallest unit of information representing 0 or 1.
Byte
A group of eight bits commonly used as the basic addressable memory unit.
Radix
The base of a positional number system (e.g., 2 for binary, 10 for decimal).
Two's complement
A method to represent signed integers where negative numbers are formed by inverting bits and adding one.
Floating-point
A representation for real numbers using sign, exponent and significand allowing wide dynamic range.
IEEE 754
The standard defining formats and arithmetic for floating-point numbers.
ASCII
A 7-bit character encoding standard for basic English characters and control codes.
Unicode
A universal character set assigning unique code points to characters from most world scripts.
Sampling rate
The number of audio samples taken per second when digitizing a waveform.
Quantization
The process of mapping a continuous range of amplitudes to discrete levels in digital representation.
Lossless compression
A compression method that allows perfect reconstruction of original data.
Lossy compression
A compression method that discards some information to achieve higher compression ratios.
CRC
Cyclic Redundancy Check, a polynomial-based error-detecting code for detecting transmission errors.
Hamming code
An error-correcting code that can detect and correct single-bit errors using parity bits.
Baud
The number of signal symbols transmitted per second over a communication channel.
Bit rate
The number of information bits transmitted per second.
Chroma subsampling
A technique that reduces colour resolution relative to luminance to save bandwidth in video.
Mantissa (Significand)
The part of a floating-point number that contains its significant digits.
Bias (in IEEE 754)
A fixed value added to the exponent to allow representation of positive and negative exponents.

Practice Questions

  1. Convert decimal 237 to binary. / दशमलव 237 को द्विआधार में बदलिए।
    Show answer

    Step 1: Divide 237 by 2 repeatedly and record remainders. 237 ÷ 2 = 118 remainder 1 118 ÷ 2 = 59 remainder 0 59 ÷ 2 = 29 remainder 1 29 ÷ 2 = 14 remainder 1 14 ÷ 2 = 7 remainder 0 7 ÷ 2 = 3 remainder 1 3 ÷ 2 = 1 remainder 1 1 ÷ 2 = 0 remainder 1 Step 2: Read remainders from last to first: 11101101₂. Therefore 237₁₀ = 11101101₂. Hindi: चरण 1: 237 को 2 से बार-बार भाग करें और शेष रखिए। ऊपर दिए हुए भागफल और शेष मिलते हैं। चरण 2: शेष को नीचे से ऊपर पढ़ें: 11101101₂। अतः 237₁₀ = 11101101₂।

  2. Explain two's complement method to represent −45 in 8 bits and give the result. / 8 बिटों में −45 को दर्शाने के लिए two's complement विधि समझाइए और परिणाम दीजिए।
    Show answer

    Method: To get two's complement of a negative integer, write its positive binary in the desired bit width, invert all bits (one's complement), then add 1. Step 1: +45 in 8 bits: 45₁₀ = 32+8+4+1 = bits 00101101. Step 2: Invert bits → 11010010. Step 3: Add 1 → 11010010 + 1 = 11010011. Result: −45 in 8-bit two's complement is 11010011₂. Verify by interpreting 11010011 as unsigned 211; 211 − 256 = −45. Hindi: विधि: पहले +45 को 8-बिट बाइनरी में लिखें (00101101), बिट्स उलटें → 11010010, फिर 1 जोड़ें → 11010011। इस तरह −45 का 8-बिट two's complement 11010011₂ होगा। सत्यापन: unsigned 211 − 256 = −45।

  3. What is IEEE 754 single precision representation of 6.5? Show sign, exponent and fraction fields. / 6.5 का IEEE 754 single precision प्रतिनिधित्व क्या है? साइन, एक्सपोनेंट और फ्रैक्शन फील्ड दिखाइए।
    Show answer

    Step 1: Convert 6.5 to binary: 6 = 110₂ and 0.5 = 0.1₂ so 6.5 = 110.1₂. Step 2: Normalize to 1.F × 2^E: 110.1₂ = 1.101 × 2^2. Step 3: Sign bit S = 0 (positive). Step 4: Exponent E = 2; biased exponent = E + bias = 2 + 127 = 129 which is 10000001₂ (8 bits). Step 5: Fraction (mantissa) is the bits after the leading 1: .101 followed by zeros to fill 23 bits → 10100000000000000000000. Final 32 bits: sign 0, exponent 10000001, fraction 10100000000000000000000. Written together: 0 10000001 10100000000000000000000. Hindi: चरण 1: 6.5 = 110.1₂। चरण 2: सामान्यीकृत रूप 1.101 × 2^2। साइन = 0। बायस्ड एक्सपोनेंट = 2+127 = 129 = 10000001₂। फ्रैक्शन = 101000... (23 बिट्स)। अतः 0 10000001 10100000000000000000000।

  4. Calculate storage needed for a 800×600 image with 24-bit colour, uncompressed. / 24-बिट रंग के साथ 800×600 छवि के बिना संपीड़न के लिए आवश्यक भंडारण निकालिए।
    Show answer

    Formula: bytes = width × height × bits_per_pixel / 8. Compute: 800 × 600 × 24 / 8 = 800 × 600 × 3 = 1,440,000 bytes. Convert to megabytes (decimal MB): 1,440,000 / 1,000,000 = 1.44 MB. If you use 1 MiB = 2^20 bytes, size ≈ 1,440,000 / 1,048,576 ≈ 1.373 MB (MiB). Hindi: सूत्र: बाइट्स = चौड़ाई × ऊँचाई × बिट्स प्रति पिक्सेल / 8। गणना: 800×600×24/8 = 1,440,000 बाइट्स। दशमलव MB में ≈ 1.44 MB; यदि MiB पर दिखाना हो तो ≈ 1.37 MiB।

  5. Give ASCII codes for characters 'A', 'a' and '0'. / अक्षरों 'A', 'a' और '0' के ASCII कोड बताइए।
    Show answer

    'A' has ASCII code 65, binary 01000001. 'a' has ASCII code 97, binary 01100001. '0' (digit zero) has ASCII code 48, binary 00110000. These are from the standard ASCII table where uppercase letters start at 65 and lowercase at 97; digits '0'–'9' occupy 48–57. Hindi: 'A' = 65 (01000001₂), 'a' = 97 (01100001₂), '0' = 48 (00110000₂)। ये ASCII तालिका के मान हैं।

  6. A PCM audio file is 2 minutes long, mono, 16-bit samples at 22.05 kHz. Calculate approximate file size in MB. / एक PCM ऑडियो फाइल 2 मिनट लंबी है, मोनो, 16-बिट सैम्पल, 22.05 kHz पर। अनुमानित फ़ाइल आकार MB में निकालिए।
    Show answer

    Use formula: size (bytes) = sampling_rate × bits_per_sample × channels × duration_seconds / 8. Compute: sampling_rate = 22,050 Hz, bits_per_sample = 16, channels = 1, duration = 2 minutes = 120 seconds. Size = 22,050 × 16 × 1 × 120 / 8 = 22,050 × 2 × 120 = 22,050 × 240 = 5,292,000 bytes. Convert to MB: 5,292,000 / 1,000,000 ≈ 5.292 MB (or using MiB: /1,048,576 ≈ 5.05 MiB). Hindi: सूत्र लागू करके: 22,050×16×1×120/8 = 5,292,000 बाइट ≈ 5.29 MB (प्राथमिक MB के अनुरूप)।

  7. Explain how a CRC detects burst errors better than a simple parity bit. / CRC किस प्रकार एक साधारण parity बिट की तुलना में burst errors का बेहतर पता लगाता है, समझाइए।
    Show answer

    Parity adds one bit so that the number of 1s in a block is even (or odd). It detects any odd number of bit flips but fails if an even number of bits flip or if errors cancel out. Parity gives no information about where errors occurred and cannot detect many multi-bit or burst errors. CRC treats the bit sequence as a polynomial over GF(2) and divides it by a chosen generator polynomial. The remainder (CRC bits) is appended. At the receiver the same division is done; a non-zero remainder indicates an error. Well-chosen CRC polynomials can detect all single-bit errors, all double-bit errors separated by less than a polynomial-specific distance, and all burst errors up to a fixed length (where burst length less than or equal to the degree of the polynomial is guaranteed to be detected). Because CRC checks linear combinations of bits weighted by polynomial powers, many structured errors (like contiguous bit flips in a burst) change the remainder and are detected, whereas parity often misses even-length bursts. Therefore CRC provides much stronger detection properties suitable for noisy channels. Hindi: parity केवल किसी ब्लॉक में 1 की कुल संख्या की विषमता देखता है और सम संख्या वाली त्रुटियों या कुछ burst त्रुटियों को नहीं पकड़ता। CRC संदेश को एक बहुपद मानकर जेनरेटर बहुपद से भाग कर शेष जोड़ता है; उपयुक्त जेनरेटर चुनने पर अधिकांश single-bit, double-bit और एक निश्चित लंबाई तक की burst त्रुटियाँ शेष बदल देती हैं और पकड़ी जाती हैं। इसलिए CRC parity की तुलना में burst errors को बेहतर ढंग से पकड़ता है।

  8. Describe Huffman coding in brief and why frequent symbols get shorter codes. / संक्षेप में Huffman कोडिंग बताइए और क्यों बारंबार आने वाले प्रतीकों को छोटे कोड मिलते हैं।
    Show answer

    Huffman coding is a variable-length, prefix-free coding technique built from symbol frequencies. The algorithm: start with a list of symbols with their frequencies; repeatedly merge the two least-frequent symbols/nodes into a parent node whose frequency equals their sum; continue until one root remains. The binary code for each symbol is the sequence of left/right choices from root to its leaf. Because less frequent symbols are merged earlier and end up deeper in the tree, they receive longer codewords; frequent symbols remain nearer the root and get shorter codewords. This minimises the weighted average code length given the symbol frequencies, making Huffman optimal for symbol-by-symbol coding with known probabilities. In practice, Huffman codes reduce average bits per symbol compared to fixed-length coding when symbol frequencies are non-uniform. Hindi: Huffman कोडिंग प्रतीक की आवृत्तियों पर आधारित है; सबसे कम आवृत्ति वाले दो नोड बार-बार जोड़े जाते हैं ताकि अंत में बारंबार आने वाले प्रतीक रूट के पास रहें और छोटे कोड प्राप्त करें, जबकि दुर्लभ प्रतीक गहरे रहें और लंबे कोड लें। यह औसत कोड लंबाई को कम करता है।

  9. If a serial link uses Manchester coding and the data bit rate is 1 Mbps, what is the required bandwidth compared to NRZ? / यदि एक सीरियल लिंक Manchester कोडिंग का उपयोग करती है और डेटा बिट दर 1 Mbps है, तो यह NRZ की तुलना में आवश्यक बैंडविड्थ कैसी होगी?
    Show answer

    Manchester encoding guarantees at least one transition per bit period (a mid-bit transition) so its fundamental frequency components are roughly twice that of NRZ for the same data rate. Therefore Manchester requires about twice the bandwidth of NRZ to transmit the same data bit rate. Concretely, for 1 Mbps data, Manchester's fundamental spectral content behaves like a 2 MHz component, so approximate required bandwidth is about double that of NRZ. Note this is an approximate rule; exact bandwidth depends on pulse shaping and spectral requirements. Hindi: Manchester में हर बिट अवधि में परिवर्तन होता है जिससे मूल आवृत्ति NRZ से लगभग दोगुनी हो जाती है; इसलिए समान बिट दर के लिए Manchester को लगभग दो गुना बैंडविड्थ की आवश्यकता होती है। अतः 1 Mbps के लिए लगभग 2 MHz के बराबर बैंडविड्थ आवश्यकता मानी जा सकती है।

  10. Show conversion: Hexadecimal 3A5 to binary and decimal. / हेक्साडेसिमल 3A5 को द्विआधार और दशमलव में बदलकर दिखाइए।
    Show answer

    Hex 3A5: break into digits 3, A and 5. 3 = 0011₂, A (10) = 1010₂, 5 = 0101₂. Concatenate to get 0011 1010 0101₂. Dropping leading zeros gives 1110100101₂. Decimal: 3×16^2 + 10×16^1 + 5×16^0 = 3×256 + 10×16 + 5 = 768 + 160 + 5 = 933₁₀. So 3A5₁₆ = 1110100101₂ = 933₁₀. Hindi: हेक्स 3A5 के लिए 3=0011, A=1010, 5=0101 अतः बाइनरी 001110100101₂ -> 1110100101₂। दशमलव गणना: 3×256 + 10×16 +5 = 933। अतः 3A5₁₆ = 1110100101₂ = 933₁₀।

Related Laws & Principles

Explore all

Foundational laws & principles connected to this chapter — tap to open in the Laws Explorer.

Loading related laws…
Sourced from 0 content files · LLOS Learn · browse all chapters