LC Computer Science cheat sheet
LC Computer Science · Keep the key ideas within reach.
Practices and principles
Computational thinking has five reusable elements: abstraction, decomposition, pattern recognition/generalisation, algorithm design and evaluation.
Decomposition splits a problem into sub-problems that can be solved, tested and debugged independently; abstraction removes detail that is irrelevant to the question being answered.
A valid algorithm is finite (it terminates), definite (every step is unambiguous), effective (every step is executable) and produces output for valid input.
Waterfall performs analysis, design, implementation, testing, deployment and maintenance once; iterative and incremental models repeat the cycle and deliver working increments.
A functional requirement states behaviour ("search returns matching records"); a non-functional requirement states a quality constraint such as response time, security, usability or portability.
Test levels run unit (one function) → integration (interfaces between modules) → system (whole product) → acceptance (user or business sign-off).
Black-box test cases are derived from the specification; white-box (glass-box) cases are derived from code paths and branches; boundary values and invalid input are always included.
A test case records input, preconditions, expected result and actual result; the test passes only when actual output equals expected output.
In version control, a commit is a snapshot, a branch is an independent line of development, a merge combines branches, and a conflict arises when both branches change the same lines of a file.
Core concepts
n bits encode 2^n distinct values; 8 bits give 0–255 unsigned or −128 to 127 in two's complement, where negation is bitwise NOT then add 1; one hex digit equals exactly four bits, so one byte is two hex digits.
Binary prefixes are powers of 1024: 1 KiB = 1024 B, 1 MiB = 1024 KiB, 1 GiB = 1024 MiB; decimal prefixes (kB, MB, GB) are powers of 1000.
Fetch–decode–execute repeats: the program counter addresses the next instruction via MAR, the instruction arrives in MDR then CIR, is decoded and executed, and the PC is incremented; the accumulator holds ALU operands and results.
Boolean identities include A·A = A, A + A′ = 1 and A·A′ = 0; De Morgan's laws are (A·B)′ = A′ + B′ and (A + B)′ = A′·B′.
TCP is connection-oriented, ordered, acknowledged and retransmits lost segments; UDP is connectionless and unacknowledged with lower latency - choose UDP for live media and DNS queries, TCP for web pages and file transfer.
Private IPv4 ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16; a /24 mask of 255.255.255.0 leaves 8 host bits, giving 254 usable host addresses.
Linear search is O(n) and works on unsorted data; binary search is O(log n) but requires sorted data with random access; bubble, insertion and selection sort are O(n²), while merge sort is O(n log n) in all cases and needs O(n) extra space.
Recursion requires a base case plus a recursive case that moves toward it; every call pushes a stack frame, so excessive depth causes a stack overflow.
SQL: SELECT columns FROM table WHERE condition ORDER BY column; INNER JOIN returns only matching rows while LEFT JOIN keeps every left-table row; a primary key is unique and non-null and a foreign key must match an existing primary key value or be null.
Computer science in practice
GDPR, operating in Ireland with the Data Protection Act 2018, requires a lawful basis, data minimisation, accuracy and storage limitation, and grants rights of access, rectification, erasure and portability; fines reach €20 million or 4% of global annual turnover, whichever is higher.
Security decision rules: never build SQL by string concatenation (use parameterised queries), hash passwords with a unique per-user salt, escape output to prevent XSS, and protect data in transit with TLS.
Copyright protects code automatically from the moment of creation; patents protect novel technical inventions for up to 20 years; copyleft licences such as GPL require derivative works to stay open, permissive licences such as MIT and Apache-2.0 do not.
WCAG is organised by POUR - Perceivable, Operable, Understandable, Robust; level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text.
Supervised learning uses labelled data (classification predicts a category, regression predicts a number); unsupervised learning finds structure in unlabelled data by clustering; biased or unrepresentative training data yields biased predictions.
An embedded system is a computer dedicated to a specific control task inside a larger device, typically running fixed firmware with real-time deadlines and constrained memory, power and processing.
Environmental costs of computing include data-centre electricity, energy and materials in device manufacture, and e-waste; mitigation includes design for repair, formal recycling of rare metals and power management.
Continuous integration merges changes into a shared repository frequently and runs automated build and tests on every merge; continuous delivery keeps each passing build in a deployable state.
The digital divide is the gap between those with reliable devices, connectivity and digital skills and those without, and it affects access to education, employment and public services.