0% found this document useful (0 votes)
2 views6 pages

Lec2 Question

The document outlines key concepts in algorithm analysis, including correctness, time and space efficiency, and optimality. It distinguishes between empirical and theoretical analysis, explaining their methodologies and limitations, and discusses time complexity in terms of best, worst, and average cases. Additionally, it covers asymptotic notations such as Big-O, Big-Ω, and Big-Θ, along with examples of time complexities for various algorithms.

Uploaded by

marwansitten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Lec2 Question

The document outlines key concepts in algorithm analysis, including correctness, time and space efficiency, and optimality. It distinguishes between empirical and theoretical analysis, explaining their methodologies and limitations, and discusses time complexity in terms of best, worst, and average cases. Additionally, it covers asymptotic notations such as Big-O, Big-Ω, and Big-Θ, along with examples of time complexities for various algorithms.

Uploaded by

marwansitten
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

✅ Basic Concepts

Q1: What are the key issues in the analysis of algorithms?


A1:

 Correctness

 Time efficiency

 Space efficiency

 Optimality

✅ Empirical vs Theoretical Analysis

Q2: What is empirical analysis of algorithm efficiency?


A2: It involves running the algorithm on a sample of inputs and measuring the
time (e.g., in milliseconds) or counting the number of operations.

Q3: Why is empirical analysis less useful?


A3:

 Requires implementation

 Must test on many datasets

 Hard to identify general patterns

Q4: What is theoretical analysis of time efficiency?


A4: It estimates time by counting how often the basic operation is performed as a
function of input size (n), giving a general performance model.

✅ Basic Operation and Input Size

Q5: What is a basic operation in algorithm analysis?


A5: The operation that most contributes to the total running time of the algorithm.

Q6: Give an example of a basic operation in a graph problem.


A6: Visiting a vertex or traversing an edge.
✅ Best, Worst, and Average Cases

Q7: What is the worst-case time complexity?


A7: It is the maximum number of operations an algorithm performs over all
possible inputs of a given size.

Q8: What is the average-case time complexity?


A8: The expected number of operations over all inputs of size n, assuming a known
distribution.

✅ Growth Rates and Orders of Growth

Q9: What is the order of growth?


A9: It describes how the running time of an algorithm increases as the input size
increases, focusing on the asymptotic behavior.

Q10: What are the common efficiency classes?


A10:

 O(1): Constant

 O(log n): Logarithmic

 O(n): Linear

 O(n log n): Linearithmic

 O(n²): Quadratic

 O(2ⁿ): Exponential

 O(n!): Factorial

✅ Asymptotic Notations

Q11: What is Big-O notation?


A11: Represents the upper bound of an algorithm's running time.
Example: If f(n)≤c⋅g(n)f(n) \leq c \cdot g(n)f(n)≤c⋅g(n) for n≥n0n \geq n_0n≥n0,
then f(n)∈O(g(n))f(n) \in O(g(n))f(n)∈O(g(n))

Q12: What is Big-Ω notation?


A12: Represents the lower bound of an algorithm's running time.
Example: If f(n)≥c⋅g(n)f(n) \geq c \cdot g(n)f(n)≥c⋅g(n) for n≥n0n \geq n_0n≥n0,
then f(n)∈Ω(g(n))f(n) \in \Omega(g(n))f(n)∈Ω(g(n))

Q13: What is Big-Θ notation?


A13: Represents a tight bound (both upper and lower) on the running time.
Example: If c1⋅g(n)≤f(n)≤c2⋅g(n)c_1 \cdot g(n) \leq f(n) \leq c_2 \cdot g(n)c1
⋅g(n)≤f(n)≤c2⋅g(n) for n≥n0n \geq n_0n≥n0, then f(n)∈Θ(g(n))f(n) \in \
Theta(g(n))f(n)∈Θ(g(n))

✅ Examples and Applications

Q14: What is the time complexity of a single for-loop running from 1 to n?


A14: O(n)O(n)O(n)

Q15: What is the time complexity of a nested loop where both loops run from
1 to n?
A15: O(n2)O(n^2)O(n2)

Q16: What is the time complexity of multiplying two square matrices of order
n?
A16: O(n3)O(n^3)O(n3)

✅ Multiple Choice Questions

Q1: Which of the following is NOT a key issue in algorithm analysis?


A) Time efficiency
B) Space efficiency
C) Syntax correctness
D) Optimality
✅ Correct Answer: C
Q2: What is the primary goal of theoretical analysis of algorithms?
A) To build user-friendly interfaces
B) To determine execution speed based on machine type
C) To count the number of basic operations as a function of input size
D) To find syntax errors
✅ Correct Answer: C

Q3: In empirical analysis, which of the following is typically measured?


A) Number of users
B) Code readability
C) Execution time in milliseconds
D) Compilation time
✅ Correct Answer: C

Q4: What is a "basic operation" in algorithm analysis?


A) The operation that appears first in the code
B) The operation contributing most to total running time
C) The operation with the smallest time
D) An operation performed only once
✅ Correct Answer: B

Q5: Which notation represents the upper bound of algorithm growth?


A) Ω (Omega)
B) Θ (Theta)
C) O (Big-O)
D) α (Alpha)
✅ Correct Answer: C

Q6: What is the time complexity of the following loop?


for (i = 1; i <= n; i++) { y = y + 9; }
A) O(1)
B) O(log n)
C) O(n)
D) O(n²)
✅ Correct Answer: C

Q7: What type of efficiency class does n log n belong to?


A) Exponential
B) Linearithmic
C) Quadratic
D) Cubic
✅ Correct Answer: B

Q8: What does Θ(g(n)) represent in asymptotic notation?


A) Only the upper bound
B) Only the lower bound
C) Both upper and lower bounds (tight bound)
D) Neither bound
✅ Correct Answer: C

Q9: Which of the following is considered inefficient in terms of time


complexity?
A) O(n)
B) O(n²)
C) O(log n)
D) O(2ⁿ)
✅ Correct Answer: D

Q10: What is the input size for checking the primality of a number?
A) Number of digits in decimal
B) Number of factors
C) Binary size of n
D) Always fixed
✅ Correct Answer: C

You might also like