Semester
Subject
Year
Tribhuwan University
2076
Bachelor Level / Third Year / Fifth Semester / Science
(Design and Analysis of Algorithms)
Full Marks: 60
Pass Marks: 24
Time: 3 Hours
Candidates are required to give their answers in their own words as for as practicable.
The figures in the margin indicate full marks.
Long Answers Questions
Complexity of an algorithm is a measure of the amount of time and/or space (memory) required by an algorithm as a function of the input size .
Algorithm complexity describes how the resource usage (time or space) of an algorithm grows as the input size increases. It helps us compare algorithms and choose the most efficient one.
We express complexity using asymptotic notations, which describe the behavior of a function for large values of (i.e., as $n \to \infty$).
There are three main asymptotic notations:
Big-O gives the worst-case (upper bound) of an algorithm's growth rate.
Definition: A function if there exist positive constants and such that:
Geometrical Interpretation: The graph of lies on or below the graph of for all values beyond . It acts as a ceiling on the growth.
Example: If , then because for and : $3n + 2 \leq 4n$ for all
Big-Omega gives the best-case (lower bound) of an algorithm's growth rate.
Definition: A function if there exist positive constants and such that:
Geometrical Interpretation: The graph of lies on or above the graph of for all values beyond . It acts as a floor on the growth.
Example: If , then because for and : $3n + 2 \geq 3n$ for all
Big-Theta gives the exact/tight bound — the function grows at the same rate as .
Definition: A function if there exist positive constants , , and such that:
Geometrical Interpretation: The graph of is sandwiched between and for all values beyond . The function is bounded both above and below.
Example: If , then because for , , and : $3n \leq 3n + 2 \leq 4n$ for all
| Notation | Bound Type | Meaning | Symbol |
|---|---|---|---|
| Upper Bound | Ceiling | ||
| Lower Bound | Floor | ||
| Tight Bound | Sandwich |
Imagine a graph with on the x-axis and on the y-axis:

Asymptotic notations provide a mathematical framework to classify algorithms based on their efficiency. Big-O is most commonly used in practice to describe worst-case performance, while Big-Theta gives the most precise characterization of an algorithm's complexity.
Short Answers Questions