Computability and Algorithm Complexity
Functions and Computation
Computer science at its core asks: what can and cannot be computed?
- Computable functions can be expressed as a well-defined, step-by-step algorithm
- Noncomputable functions — no algorithm exists to determine outputs for all inputs; the halting problem is the canonical example
Turing Machines
Turing machines define the theoretical boundary of computation:
- A Turing machine reads symbols on a tape, transitions between states, and writes new symbols
- Any function computable by a modern computer can be computed by a Turing machine
- The halting problem — predicting whether any given program will terminate — is undecidable and cannot be solved by any algorithmic system
The Bare Bones Language
A minimal imperative programming language that can express all Turing-computable functions using only:
- Variables (non-negative integers as bit patterns)
- Three assignment statements
- One loop control structure (while)
This illustrates that computational power does not require complexity — minimalism can be Turing-complete.
Algorithm Complexity
Complexity measures how resource requirements (time, space) scale with input size.
| Notation | Meaning |
|---|---|
| Big-O (O) | Upper bound — worst-case growth rate |
| Big-Theta (Θ) | Tight bound — exact growth rate |
Time complexity counts execution steps, not lines of code.
| Algorithm | Complexity | Example |
|---|---|---|
| Binary Search | O(log n) | Finding a value in a sorted list |
| Merge Sort | O(n log n) | Efficient sorting |
| Bubble Sort | O(n²) | Naive sorting |
| Brute-force TSP | O(n!) | Traveling Salesperson Problem |
P vs. NP
| Class | Description |
|---|---|
| P (Polynomial) | Tractable — solvable in polynomial time |
| NP (Nondeterministic Polynomial) | Verifiable in polynomial time; may not be solvable quickly |
| NP-Complete | Hardest problems in NP; if one is solved in P, all NP problems are |
| Intractable | Cannot be solved in reasonable time for large inputs |
Open question: Does P = NP? The most important unsolved problem in theoretical computer science.
Heuristic approaches — for intractable problems, approximation algorithms find "good enough" solutions (e.g., greedy algorithms for TSP).
Advanced Persistent Threats as a High-Complexity Problem
APTs exemplify computational complexity in cybersecurity: - Multiple attack stages with branching decision paths - Customized exploits targeting specific vulnerabilities - Prolonged undetected presence (months to years) - Countermeasures: SIEM platforms, behavioral analytics, AI-based anomaly detection