Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Foundations of DS & AlgorithmsEasy
Q1. What is a data structure?
- A.A specific programming language type
- B.A step-by-step problem procedure
- C.A physical hardware component unit
- D.A way to organize and store data✓ Correct
Explanation
A data structure is a way to organize, manage, and store data so that it can be accessed and modified efficiently.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q2. What does 'algorithm' mean?
- A.A compiled programming language
- B.A primitive data type definition
- C.A processing hardware component
- D.A step-by-step problem procedure✓ Correct
Explanation
An algorithm is a finite set of well-defined instructions or steps to solve a specific problem or perform a computation.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q3. Which notation is used to describe the upper bound of an algorithm's time complexity?
- A.Small-o notation
- B.Theta notation
- C.Omega notation
- D.Big-O notation✓ Correct
Explanation
Big-O notation describes the upper bound (worst case) of an algorithm's growth rate.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q4. What is the time complexity of accessing an element in an array by index?
- A.O(n)
- B.O(log n)
- C.O(1)✓ Correct
- D.O(n^2)
Explanation
Array elements can be accessed directly using their index in constant time O(1).
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q5. Which of the following is a linear data structure?
- A.Graph
- B.Array✓ Correct
- C.Heap
- D.Tree
Explanation
An array is a linear data structure where elements are stored in contiguous memory locations.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q6. What is the purpose of pseudocode?
- A.To execute low-level machine instructions
- B.To debug and test running software
- C.To compile a program into bytecode
- D.To describe an algorithm in readable form✓ Correct
Explanation
Pseudocode is used to represent an algorithm in a structured, human-readable format without worrying about syntax of a specific language.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q7. Which term refers to the amount of memory an algorithm uses?
- A.Time complexity
- B.Code complexity
- C.Space complexity✓ Correct
- D.Cyclomatic complexity
Explanation
Space complexity measures the total amount of memory space required by an algorithm as a function of input size.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q8. What is O(1) complexity called?
- A.Constant✓ Correct
- B.Quadratic
- C.Logarithmic
- D.Linear
Explanation
O(1) is called constant time complexity because the execution time does not change with input size.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q9. Which of the following is a non-linear data structure?
- A.Linked List
- B.Stack
- C.Array
- D.Tree✓ Correct
Explanation
A tree is a non-linear data structure where elements are arranged in a hierarchical manner.
Report an error in this question
Foundations of DS & AlgorithmsEasy
Q10. What is an Abstract Data Type (ADT)?
- A.A concrete implementation of a data structure
- B.A reserved programming language keyword term
- C.A specific type of comparison sorting algorithm
- D.A mathematical model defined by its behavior✓ Correct
Explanation
An ADT is a mathematical model that defines a data type by its behavior (operations) rather than its implementation.
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q11. What is the time complexity of the recurrence T(n) = 2T(n/2) + n?
- A.O(n^2)
- B.O(log n)
- C.O(n)
- D.O(n log n)✓ Correct
Explanation
By the Master Theorem (case 2), T(n) = 2T(n/2) + n gives O(n log n).
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q12. Which case of the Master Theorem applies when f(n) = Θ(n^(log_b(a)))?
- A.Case 3 applies
- B.No case applies
- C.Case 2 applies✓ Correct
- D.Case 1 applies
Explanation
Case 2 of the Master Theorem applies when f(n) = Θ(n^(log_b(a))), giving T(n) = Θ(n^(log_b(a)) * log n).
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q13. What does Omega (Ω) notation represent?
- A.Exact tight bound complexity
- B.Worst-case upper bound complexity
- C.Best-case or lower bound complexity✓ Correct
- D.Average-case expected complexity
Explanation
Omega notation provides an asymptotic lower bound on the growth rate of an algorithm.
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q14. If an algorithm has complexities O(n^2) in the worst case and Ω(n) in the best case, which is true?
- A.The algorithm always runs in O(n) time
- B.The algorithm always runs in O(n^2) time
- C.The algorithm runs in O(n log n) always
- D.Performance varies between Ω(n) and O(n^2)✓ Correct
Explanation
The algorithm's performance ranges from the lower bound Ω(n) in the best case to the upper bound O(n^2) in the worst case.
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q15. What is amortized analysis?
- A.Analyzing the worst case of each operation individually
- B.Averaging the cost of operations over a sequence✓ Correct
- C.Analyzing only the best case of each operation
- D.Computing the cost using a sorting-based analysis
Explanation
Amortized analysis averages the time required to perform a sequence of operations, giving a tighter bound than worst-case per operation.
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q16. Which growth rate is faster: O(2^n) or O(n^3)?
- A.They are the same
- B.O(n^3) is faster
- C.O(2^n) is faster✓ Correct
- D.Depends on input size
Explanation
Exponential growth O(2^n) grows much faster than polynomial growth O(n^3) for large n.
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q17. What is the time complexity of a nested loop where both loops run n times?
- A.O(n log n)
- B.O(n^2)✓ Correct
- C.O(2n)
- D.O(n)
Explanation
Two nested loops each running n times result in n × n = n^2 iterations, giving O(n^2).
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q18. In asymptotic analysis, which of these is the correct ordering from slowest to fastest growth?
- A.O(1) < O(log n) < O(n) < O(n^2)✓ Correct
- B.O(1) < O(n) < O(log n) < O(n^2)
- C.O(n) < O(log n) < O(1) < O(n^2)
- D.O(log n) < O(1) < O(n) < O(n^2)
Explanation
The correct growth order is: O(1) < O(log n) < O(n) < O(n^2).
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q19. What is the recurrence relation for binary search?
- A.T(n) = 2T(n/2) + 1
- B.T(n) = T(n-1) + 1
- C.T(n) = T(n/2) + n
- D.T(n) = T(n/2) + 1✓ Correct
Explanation
Binary search divides the problem in half each time and does constant work, giving T(n) = T(n/2) + 1.
Report an error in this question
Foundations of DS & AlgorithmsMedium
Q20. What does Theta (Θ) notation represent?
- A.Only upper bound estimate
- B.Tight bound (both upper and lower)✓ Correct
- C.Only lower bound estimate
- D.Average case analysis only
Explanation
Theta notation provides a tight bound, meaning the function grows at the same rate asymptotically (both upper and lower bounds match).
Report an error in this question
Foundations of DS & AlgorithmsHard
Q21. What is the time complexity of the recurrence T(n) = 3T(n/4) + n log n?
- A.O(n^(log_4(3)))
- B.O(n^2)
- C.O(n log^2 n)
- D.O(n log n)✓ Correct
Explanation
Using Master Theorem case 3: log_4(3) ≈ 0.79 < 1, and f(n) = n log n = Ω(n^(0.79+ε)), so T(n) = Θ(n log n).
Report an error in this question
Foundations of DS & AlgorithmsHard
Q22. Which of the following recurrences cannot be solved by the Master Theorem?
- A.T(n) = T(n-1) + n✓ Correct
- B.T(n) = 2T(n/2) + n log n
- C.T(n) = 2T(n/2) + n
- D.T(n) = 4T(n/2) + n^2
Explanation
T(n) = T(n-1) + n is not in the form T(n) = aT(n/b) + f(n) required by the Master Theorem, as it subtracts rather than divides.
Report an error in this question
Foundations of DS & AlgorithmsHard
Q23. What is the amortized cost of insertion in a dynamic array that doubles its size when full?
- A.O(1)✓ Correct
- B.O(n^2)
- C.O(log n)
- D.O(n)
Explanation
Although occasional resizing costs O(n), the amortized cost over n insertions is O(1) per insertion using aggregate analysis.
Report an error in this question
Foundations of DS & AlgorithmsHard
Q24. Using the substitution method, what is the solution to T(n) = T(n-1) + n with T(1) = 1?
- A.O(2^n)
- B.O(n log n)
- C.O(n)
- D.O(n^2)✓ Correct
Explanation
Expanding: T(n) = n + (n-1) + ... + 1 = n(n+1)/2 = O(n^2).
Report an error in this question
Foundations of DS & AlgorithmsHard
Q25. What is the lower bound for any comparison-based sorting algorithm?
- A.O(n log n)✓ Correct
- B.O(n^2)
- C.O(log n)
- D.O(n)
Explanation
Any comparison-based sorting algorithm requires at least Ω(n log n) comparisons in the worst case, proven via decision tree analysis.
Report an error in this question
Foundations of DS & AlgorithmsHard
Q26. In the potential method of amortized analysis, the amortized cost is defined as:
- A.Actual cost × potential function
- B.Actual cost + change in potential✓ Correct
- C.Actual cost - change in potential
- D.Actual cost / potential function
Explanation
In the potential method, amortized cost = actual cost + (Φ(after) - Φ(before)), where Φ is the potential function.
Report an error in this question
Foundations of DS & AlgorithmsHard
Q27. What complexity class does the problem of finding the median of an unsorted array belong to?
- A.O(n^2) minimum brute force
- B.O(n log n) using sort first
- C.O(n) using deterministic selection✓ Correct
- D.O(log n) using binary search
Explanation
The median can be found in O(n) worst-case time using the median-of-medians deterministic selection algorithm.
Report an error in this question
Foundations of DS & AlgorithmsHard
Q28. What is the space complexity of a recursive algorithm with depth d and O(1) space per call?
- A.O(d)✓ Correct
- B.O(2^d)
- C.O(d^2)
- D.O(1)
Explanation
Each recursive call adds a frame to the call stack. With depth d and O(1) per frame, total space is O(d).
Report an error in this question
Foundations of DS & AlgorithmsHard
Q29. Which of the following is true about the relationship between time and space complexity?
- A.Space complexity can exceed time complexity
- B.Space complexity cannot exceed time complexity✓ Correct
- C.Time complexity is always greater than space
- D.Time and space complexity are always equal
Explanation
An algorithm cannot use more space than time, because writing to each memory cell takes at least one time step. So space ≤ time.
Report an error in this question
Foundations of DS & AlgorithmsHard
Q30. What is the time complexity of T(n) = 2T(n/2) + n/log n?
- A.O(n)
- B.O(n log n)
- C.O(n log log n)✓ Correct
- D.O(n (log n)^2)
Explanation
This recurrence falls in a gap of the Master Theorem. Using the Akra-Bazzi method or recursion tree, T(n) = O(n log log n).
Report an error in this question