# 1.3 Data Storage & File Compression

***

## Data Storage

Memory size is actually <mark style="color:yellow;">measured in terms of powers of 2</mark>, it's a system which is more accurate has been adopted by the IEC (International Electrotechnical Commission). Internal memories such as RAM & ROM use this.

| Name             | Value                  |
| ---------------- | ---------------------- |
| Nibble           | 4 bits                 |
| Byte             | 8 bits                 |
| 1 KB (kilobyte)  | 1000 bytes             |
| 1 MB (megabyte)  | 1000 KB                |
| 1 GB (gigabyte)  | 1000 MB                |
| 1 TB (terabyte)  | 1000 GB                |
| 1 PB (petabyte)  | 1000 TB                |
| 1 KiB (kibibyte) | 1024 bytes (2¹º)       |
| 1 MiB (mebibyte) | 1048576 bytes (2²º)    |
| 1 GiB (gibibyte) | 1073741824 bytes (2³⁰) |

***

## Data Compression

Compressing data is useful as it <mark style="color:yellow;">saves storage space, reduces costs by using less bandwidth, and reduces the time taken to stream or transfer the file</mark>. There are two types of data compression:

1. Lossy
2. Lossless

### Lossy

* Upon compression, the unnecessary data is deleted
* Original file cannot be reconstructed
* Some loss of detail (lower quality in images & sound files)
* Smaller file size

{% hint style="success" %}
Sample answer:

Compression algorithm is used\
Original file cannot be restored\
Deletes unnecessary data from the file\
Removes sounds that cannot be heard by the human ear\
Reduces the sample rate & resolution
{% endhint %}

### Lossless

* Compresses a file by reducing the size of repeated areas (via RLE & Huffman)
* RLE (run-length encoding) is used to replace sequences of repeated characters with a code
* Huffman encoding replaces frequently used characters with shorter codes and the opposite
* All the data from the original file can be reconstructed
* No detail is lost
* Larger file size

{% hint style="success" %}
Sample answer:

Compression algorithm is used\
Original file can be restored\
RLE & Huffman encoding is used\
Repeated patterns are identified & indexed
{% endhint %}

***

## Exam Questions

{% embed url="<https://cdn.savemyexams.com/pdfs/data-storage-and-compression-ZtxjRzyYV9MWrnQx.pdf>" %}

***
