Data Structures and Algorithms Design Week 2 Answers
Are you looking for Data Structures and Algorithms Design Week 2 Answers ? All weeks solutions of this Swayam course are available here.
Table of Contents

Data Structures and Algorithms Design Week 2 Answers (July-Dec 2025)
Course link: Click here to visit course on Nptel Website
Question 1. What is the worst-case time complexity of Bubble Sort?
a) O(n²)
b) O(nlogn)
c) O(n)
d) O(logn)
Question 2. What is the best time complexity of the following subroutine as a function of n? Assume each instruction takes O(1) time only.
sum = 0;
for (i = 1; i < n; i = i*2)
for(j = 0; j < i; j = j+1)
sum = sum + 1;
a) O(n)
b) O(nlogn)
c) O(n²)
d) O(n²logn)
Question 3. Arrange the following in increasing order of growth: O(nlogn), O(n²), O(2ⁿ), O(n!)
a) O(nlogn) < O(n²) < O(2ⁿ) < O(n!)
b) O(nlogn) < O(2ⁿ) < O(n²) < O(n!)
c) O(n²) < O(nlogn) < O(n!) < O(2ⁿ)
d) O(2ⁿ) < O(n!) < O(n²) < O(nlogn)
Question 4. If f(n) = nlogn and g(n) = n(logn)², which is true?
a) f(n) = o(g(n))
b) f(n) = ω(g(n))
c) f(n) = Θ(g(n))
d) g(n) = o(f(n))
Question 5. Let f(n) = 2√logn, g(n) = (logn)⁵. Which of the following is true?
a) g(n) = o(f(n))
b) f(n) = o(g(n))
c) f(n) = Θ(g(n))
d) f(n) = ω(n)
**Question 6. Arrange the following functions in increasing order of asymptotic growth:
- n¹·⁵
- nlog²n
- √n logn
- n⁰·⁷⁵**
a) 3 < 4 < 2 < 1
b) 2 < 3 < 4 < 1
c) 3 < 2 < 4 < 1
d) 4 < 3 < 2 < 1
Question 7. Consider the following pseudocode:
for i = 1 to n:
j = i
while j > 1:
j = j / 2
What is the time complexity?
a) O(nlogn)
b) O(n)
c) O(logn)
d) O(n²)
Question 8. Consider the following pseudocode:
i = 2
while i <= n:
j = 2
while j <= log i:
j = j * j
i = i * 2
What is the time complexity?
a) O(logn⋅logloglogn)
b) O(logn⋅loglogn)
c) O(logn)
d) O(n)
Question 9. At each index i, the O(n) maximum subarray sum algorithm updates the running sum by:
a) Taking the maximum of the current element and the sum so far plus the current element
b) Taking the minimum of the current element and the sum so far plus the current element
c) Always adding the current element to the sum
d) Comparing the current element to the maximum sum found so far
Question 10. What is the time complexity of a brute-force solution that checks all possible subarrays and computes their sums individually?
a) O(n³)
b) O(n²)
c) O(nlogn)
d) O(n!)
These are Data Structures and Algorithms Design Week 2 Answers