Computer Science Reference Sheet
A compact revision guide covering essential concepts from programming, algorithms, data representation, databases, networking, operating systems, cybersecurity, and artificial intelligence.
Use the search box to find a topic or select Print to save a paper or PDF copy.
Showing all sections.
1. Computer Science Fundamentals
Common units
| Unit | Meaning |
|---|---|
| bit (b) | A binary digit: 0 or 1. |
| byte (B) | 8 bits. |
| kilobyte (kB) | 1,000 bytes. |
| megabyte (MB) | 1,000,000 bytes. |
| gigabyte (GB) | 1,000,000,000 bytes. |
| kibibyte (KiB) | 1,024 bytes. |
| mebibyte (MiB) | 1,024 KiB. |
| gibibyte (GiB) | 1,024 MiB. |
2. Number Systems and Data Representation
| System | Base | Allowed digits |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0–7 |
| Decimal | 10 | 0–9 |
| Hexadecimal | 16 | 0–9, A–F |
Place-value rule
For a number written in base \(b\), each digit is multiplied by a power of \(b\) according to its position.
Example:
(1011)₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰
= 8 + 0 + 2 + 1
= (11)₁₀
Useful conversions
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 25 | 11001 | 31 | 19 |
| 32 | 100000 | 40 | 20 |
Binary addition rules
0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 (write 0, carry 1) 1 + 1 + 1 = 11 (write 1, carry 1)
Two's complement
Two's complement is commonly used to represent signed integers in binary. For an \(n\)-bit value, its signed range is \(-2^{n-1}\) to \(2^{n-1}-1\).
For example, an 8-bit two's-complement integer ranges from −128 to 127.
3. Programming Fundamentals
| Concept | Purpose |
|---|---|
| Variable | Names a value that may change. |
| Constant | Represents a value intended not to change. |
| Data type | Defines the kind of value and supported operations. |
| Condition | Selects a path according to a test. |
| Loop | Repeats a block of instructions. |
| Function | Packages reusable behaviour, optionally with inputs and a return value. |
| Array / list | Stores a collection of values. |
| Debugging | Finds and fixes problems in a program. |
Common data types
- Integer: Whole numbers.
- Float / real: Approximate or floating-point numbers in many languages.
- Boolean: True or false.
- String: Text.
- Character: A character value in languages that provide this type.
Control structures
Sequence: instructions run in order.
Selection:
if condition:
do one action
else:
do another action
Iteration:
repeat an action while a condition is true.
4. Algorithms and Complexity
An algorithm is a finite, well-defined sequence of steps for solving a problem or performing a computation.
Core properties
- Clearly specified steps.
- Defined inputs and outputs where appropriate.
- Effective operations.
- Termination for algorithms intended to finish.
Common Big-O growth rates
| Complexity | Name | Typical example |
|---|---|---|
| O(1) | Constant | Array access by index, under the usual model. |
| O(log n) | Logarithmic | Binary search on sorted data. |
| O(n) | Linear | Scanning a list once. |
| O(n log n) | Linearithmic | Common efficient comparison sorting algorithms. |
| O(n²) | Quadratic | Two nested loops over the same input size. |
| O(2ⁿ) | Exponential | Some exhaustive recursive search approaches. |
Searching and sorting
- Linear search: Checks items one by one; worst-case time O(n).
- Binary search: Repeatedly halves a sorted search range; time O(log n).
- Merge sort: A divide-and-conquer sorting algorithm with O(n log n) time in its standard form.
- Bubble sort: Repeatedly swaps adjacent out-of-order elements; typical implementation has O(n²) worst-case time.
5. Data Structures
| Structure | Organisation | Common use |
|---|---|---|
| Array | Indexed sequence | Fast indexed access. |
| Linked list | Nodes linked by references | Insertions and deletions when the relevant position is known. |
| Stack | LIFO | Undo operations, function calls. |
| Queue | FIFO | Task scheduling, waiting lines. |
| Tree | Hierarchical nodes | Hierarchies and search structures. |
| Graph | Vertices and edges | Roads, networks, relationships. |
| Hash table | Keys mapped to buckets or slots | Fast average-case lookup by key. |
LIFO: Last In, First Out. FIFO: First In, First Out.
Typical operation costs
| Structure | Typical operation | Typical cost |
|---|---|---|
| Array | Access by index | O(1) |
| Array | Search unsorted values | O(n) |
| Stack | Push / pop | O(1) |
| Queue | Enqueue / dequeue | O(1) with a suitable implementation |
| Hash table | Lookup | O(1) average case; O(n) worst case in common implementations |
| Balanced search tree | Search / insert / delete | O(log n) |
These costs assume typical implementations and conditions; they are not guarantees for every implementation.
6. Databases and SQL
- Database: An organised collection of data.
- DBMS: Software used to create, manage, query, and protect databases.
- Primary key: Uniquely identifies each row in a table.
- Foreign key: References a key in another or the same table to represent a relationship.
- Normalization: Organises relational data to reduce unwanted redundancy and update anomalies.
- Transaction: A logical unit of database work.
Common SQL commands
| Command | Purpose |
|---|---|
| SELECT | Reads data. |
| INSERT | Adds rows. |
| UPDATE | Changes existing rows. |
| DELETE | Removes rows. |
| CREATE | Creates database objects. |
| ALTER | Changes an object's definition. |
| DROP | Removes a database object. |
Example query
SELECT name, marks FROM students WHERE marks >= 80 ORDER BY marks DESC;
Useful aggregate functions
COUNT(), SUM(), AVG(), MIN(), and MAX().
ACID transactions
- Atomicity: All-or-nothing transaction behaviour.
- Consistency: Transactions preserve defined database rules.
- Isolation: Concurrent transactions are controlled according to the chosen isolation level.
- Durability: Committed changes persist according to the system's guarantees.
7. Computer Networks
Network types
- PAN: Personal Area Network.
- LAN: Local Area Network.
- MAN: Metropolitan Area Network.
- WAN: Wide Area Network.
Devices
| Device | Main role |
|---|---|
| Router | Forwards packets between networks. |
| Switch | Forwards frames within a local network using MAC addresses. |
| Access point | Connects wireless devices to a network. |
| Modem | Adapts signals for a particular communication link or access technology. |
| Firewall | Allows or blocks traffic according to security rules. |
Common protocols
| Protocol | Purpose |
|---|---|
| IP | Addresses and routes packets between networks. |
| TCP | Provides a reliable, ordered byte stream between endpoints. |
| UDP | Provides datagrams without TCP's built-in delivery and ordering guarantees. |
| DNS | Resolves domain names to records such as IP addresses. |
| HTTP / HTTPS | Protocols used for web communication; HTTPS protects HTTP with TLS. |
| DHCP | Automatically provides network configuration to clients. |
| SMTP | Used to send and relay email. |
| SSH | Provides secure remote login and other secure communication features. |
Performance terms
- Bandwidth: A link's capacity to carry data.
- Throughput: The actual rate of successful data transfer.
- Latency: Delay in communication.
- Packet loss: Packets that fail to reach their destination.
8. Operating Systems
- Kernel: Core OS component that manages fundamental system operations.
- Process: A running instance of a program.
- Thread: A sequence of execution within a process.
- Scheduler: Selects which ready process or thread runs next.
- Virtual memory: Provides process address spaces and supports flexible memory management.
- File system: Defines how files and directories are organised and stored.
- Device driver: Software that enables communication between the OS and hardware.
- System call: A defined interface for requesting an operating-system service.
Process states
New → Ready → Running → Terminated
^ |
| v
└── Waiting
Scheduling algorithms
- FCFS: First Come, First Served.
- SJF: Shortest Job First.
- Priority scheduling: Uses assigned priorities.
- Round Robin: Shares CPU time using time slices.
Deadlock conditions
- Mutual exclusion.
- Hold and wait.
- No preemption.
- Circular wait.
9. Cybersecurity and Digital Safety
The CIA triad
- Confidentiality: Prevents unauthorized disclosure.
- Integrity: Protects against unauthorized or improper changes.
- Availability: Keeps systems and information accessible to authorized users.
Essential terms
| Term | Meaning |
|---|---|
| Phishing | Deceptive messages intended to manipulate recipients. |
| Malware | Software designed for malicious or unauthorized purposes. |
| Encryption | Transforms data so it can be read only with the appropriate decryption capability. |
| Hashing | Maps data to a fixed-size digest using a hash function. |
| MFA | Authentication using two or more different factor types. |
| Firewall | Filters traffic according to configured rules. |
| Backup | A separate copy of data used for recovery. |
Good security habits
- Use unique passwords and a reputable password manager.
- Enable multifactor authentication.
- Install security updates from trusted sources.
- Verify unexpected requests through an independent, trusted channel.
- Keep protected backups of important information.
- Grant applications only the permissions they need.
10. Artificial Intelligence Fundamentals
Key terms
Learning approaches
- Supervised learning: Learns from labelled examples.
- Unsupervised learning: Finds patterns without target labels for every example.
- Reinforcement learning: Learns action strategies from reward signals.
Common evaluation metrics
- Accuracy: Correct predictions divided by all predictions.
- Precision: True positives divided by predicted positives.
- Recall: True positives divided by actual positives.
- Mean squared error: Average squared difference between predicted and actual values.
11. Quick Revision Checklist
Use this list to check which concepts you can already explain.