CSC262 · 2079 · 5 marks
Write short notes (Any two): a) Big Oh, Big Omega and Big Theta b) Tractable and Intractable Problems c) Chomsky Hierarchy
Write short notes (Any two): a) Big Oh, Big Omega and Big Theta b) Tractable and Intractable Problems c) Chomsky Hierarchy [5]
Quick answer
These are asymptotic notations used to describe the time or space complexity of algorithms as the input size n grows.
Short Notes (Any Two)
a) Big Oh, Big Omega, and Big Theta
1. Big Oh Notation O(g(n)) -- Upper Bound
Definition: f(n) = O(g(n)) if there exist positive constants c and n₀ such that:
f(n) ≤ c · g(n) for all n ≥ n₀
- It gives the worst-case (upper bound) complexity.
- Example: If f(n) = 3n² + 2n, then f(n) = O(n²)
2. Big Omega Notation Ω(g(n)) -- Lower Bound
Definition: f(n) = Ω(g(n)) if there exist positive constants c and n₀ such that:
f(n) ≥ c · g(n) for all n ≥ n₀
- It gives the best-case (lower bound) complexity.
- Example: f(n) = 3n² + 2n, then f(n) = Ω(n²)
3. Big Theta Notation Θ(g(n)) -- Tight Bound
Definition: f(n) = Θ(g(n)) if there exist positive constants c₁, c₂, and n₀ such that:
c₁ · g(n) ≤ f(n) ≤ c₂ · g(n) for all n ≥ n₀
- It gives the average/exact (tight bound) complexity.
- f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = Ω(g(n))
- Example: f(n) = 3n² + 2n, then f(n) = Θ(n²)
b) Tractable and Intractable Problems
Tractable Problems
- Problems that can be solved within reasonable time and space constraints are called tractable.
- An algorithm is said to be polynomially bounded if its complexity measure increases with n no more rapidly than a polynomial in n.
- Such problems belong to Class P -- solvable in polynomial time by a deterministic Turing Machine.
- Examples: Sorting, searching, shortest path (Dijkstra's algorithm)
Intractable Problems
- Problems that cannot be solved in polynomial time but require exponential time algorithms are called intractable or hard problems.
- An algorithm is exponentially bounded if its complexity grows exponentially with n.
- Formally, problems are intractable if the time required for any algorithm is at least f(n), where f is an exponential function of n.
- Intractability is the study of problems not solvable in polynomial time.
- Such problems are associated with Class NP -- solvable in polynomial time by a non-deterministic Turing Machine.
- Examples: Travelling Salesman Problem (TSP), 0/1 Knapsack, Hamiltonian Cycle
| Feature | Tractable | Intractable |
|---|---|---|
| Time complexity | Polynomial O(nᵏ) | Exponential O(2ⁿ) |
| Class | Class P | Class NP / NP-Hard |
| Solvability | Practically solvable | Not practically solvable |
c) Chomsky Hierarchy
The Chomsky Hierarchy (proposed by Noam Chomsky) classifies formal grammars and languages into four levels based on their generative power and the type of automaton required to recognize them.
| Type | Grammar | Language | Automaton |
|---|---|---|---|
| Type 0 | Unrestricted Grammar | Recursively Enumerable | Turing Machine |
| Type 1 | Context-Sensitive Grammar (CSG) | Context-Sensitive Language | Linear Bounded Automaton |
| Type 2 | Context-Free Grammar (CFG) | Context-Free Language | Pushdown Automaton |
| Type 3 | Regular Grammar | Regular Language | Finite Automaton |
Description of Each Level
Type 3 -- Regular Grammar:
- Productions of the form: A → aB or A → a
- Recognized by Finite Automata (FA)
- Least powerful; used in lexical analysis
Type 2 -- Context-Free Grammar (CFG):
- Productions of the form: A → α (where A is a single non-terminal)
- Recognized by Pushdown Automata (PDA)
- Used in programming language syntax (parsers)
Type 1 -- Context-Sensitive Grammar (CSG):
- Productions of the form: αAβ → αγβ (context matters)
- Recognized by Linear Bounded Automata (LBA)
- More powerful than CFG
Type 0 -- Unrestricted Grammar:
- No restrictions on productions
- Recognized by Turing Machines
- Most powerful; generates recursively enumerable languages
Hierarchy: Type 3 ⊂ Type 2 ⊂ Type 1 ⊂ Type 0
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.