Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Algorithm Design TechniquesEasy
Q1. What is the divide and conquer strategy?
- A.Breaking into subproblems, solving, and combining✓ Correct
- B.Solving all problems using bottom-up iteration
- C.Using a greedy approach at each step
- D.Solving problems by trying all possibilities
Explanation
Divide and conquer breaks a problem into smaller subproblems, solves each recursively, and combines their solutions to solve the original problem.
Report an error in this question
Algorithm Design TechniquesEasy
Q2. What is a greedy algorithm?
- A.An algorithm making locally optimal choices each step✓ Correct
- B.An algorithm that solves all subproblems first
- C.An algorithm that uses backtracking for search
- D.An algorithm that tries all possible combinations
Explanation
A greedy algorithm makes the best choice available at each step without reconsidering previous choices, hoping to reach a globally optimal solution.
Report an error in this question
Algorithm Design TechniquesEasy
Q3. What is memoization?
- A.Writing memos about code documentation
- B.A type of sorting with memory optimization
- C.Memorizing the algorithm steps by heart
- D.Caching results of function calls for reuse✓ Correct
Explanation
Memoization stores the results of expensive function calls and returns the cached result when the same inputs occur again, avoiding redundant computation.
Report an error in this question
Algorithm Design TechniquesEasy
Q4. Which of the following is an example of divide and conquer?
- A.Merge sort✓ Correct
- B.Linear search
- C.Insertion sort
- D.Bubble sort
Explanation
Merge sort is a classic divide and conquer algorithm: it divides the array in half, sorts each half, and merges the results.
Report an error in this question
Algorithm Design TechniquesEasy
Q5. What is backtracking?
- A.Sorting data elements in reverse descending order
- B.Trying solutions and abandoning invalid paths early✓ Correct
- C.Going back to the start of an algorithm run
- D.Reversing the input data before processing
Explanation
Backtracking explores all potential solutions by building them incrementally and abandoning (backtracking from) paths that cannot lead to valid solutions.
Report an error in this question
Algorithm Design TechniquesEasy
Q6. What is dynamic programming?
- A.A type of greedy algorithm with memoization
- B.Solving problems by storing overlapping subproblem results✓ Correct
- C.Programming that changes dynamically at runtime
- D.An algorithm that uses only recursion for solving
Explanation
Dynamic programming solves problems by dividing them into overlapping subproblems, solving each once, and storing results to avoid redundant computation.
Report an error in this question
Algorithm Design TechniquesEasy
Q7. What is brute force in algorithm design?
- A.An optimized search using heuristics
- B.Trying all possible solutions exhaustively✓ Correct
- C.The most efficient approach available
- D.A divide and conquer optimization
Explanation
Brute force tries every possible solution systematically, checking each one until the correct answer is found. It is simple but often inefficient.
Report an error in this question
Algorithm Design TechniquesEasy
Q8. What two properties must a problem have to be solvable by dynamic programming?
- A.Optimal substructure and overlapping subproblems✓ Correct
- B.Linear structure and constant time operations
- C.Greedy choice property and unique solution
- D.Sorting and searching capabilities
Explanation
Dynamic programming requires optimal substructure (optimal solution uses optimal solutions to subproblems) and overlapping subproblems (same subproblems are solved multiple times).
Report an error in this question
Algorithm Design TechniquesEasy
Q9. Which approach builds solutions from smallest subproblems to larger ones?
- A.Greedy approach
- B.Top-down approach
- C.Bottom-up (tabulation)✓ Correct
- D.Brute force approach
Explanation
Bottom-up (tabulation) starts by solving the smallest subproblems first and iteratively builds up to the solution of the original problem.
Report an error in this question
Algorithm Design TechniquesEasy
Q10. Which algorithm design paradigm does the activity selection problem use?
- A.Backtracking search approach
- B.Dynamic programming approach
- C.Divide and conquer approach
- D.Greedy algorithm approach✓ Correct
Explanation
The activity selection problem is optimally solved using a greedy approach: always select the activity that finishes earliest.
Report an error in this question
Algorithm Design TechniquesMedium
Q11. What is the time complexity of the dynamic programming solution for the 0/1 knapsack problem with n items and capacity W?
- A.O(n log n)
- B.O(2^n)
- C.O(n × W)✓ Correct
- D.O(n)
Explanation
The 0/1 knapsack DP solution fills an n × W table, where each cell is computed in O(1), giving O(n × W) time (pseudo-polynomial).
Report an error in this question
Algorithm Design TechniquesMedium
Q12. What is the coin change problem (minimum coins)?
- A.Finding minimum coins to make a target amount✓ Correct
- B.Sorting coins by their face value order
- C.Counting total coins in a collection
- D.Finding the maximum number of coins used
Explanation
The coin change problem asks for the minimum number of coins from given denominations to make a target amount. It is solved using DP.
Report an error in this question
Algorithm Design TechniquesMedium
Q13. What is the time complexity of the recursive Fibonacci without memoization?
- A.O(n)
- B.O(log n)
- C.O(n^2)
- D.O(2^n)✓ Correct
Explanation
Without memoization, the recursive Fibonacci has O(2^n) time complexity due to redundant computation of the same subproblems.
Report an error in this question
Algorithm Design TechniquesMedium
Q14. What is the greedy choice property?
- A.Always choosing the most expensive option first
- B.A locally optimal choice leads to global optimum✓ Correct
- C.A property that all algorithms must have
- D.A property unique to dynamic programming only
Explanation
The greedy choice property means that a locally optimal choice at each step will lead to a globally optimal solution.
Report an error in this question
Algorithm Design TechniquesMedium
Q15. What is the Longest Common Subsequence (LCS) problem?
- A.Finding the longest subsequence present in both sequences✓ Correct
- B.Finding the longest increasing subsequence in an array
- C.Finding the longest common substring between two strings
- D.Finding the longest common prefix of two strings
Explanation
LCS finds the longest subsequence (not necessarily contiguous) that appears in both sequences. It is solved using DP in O(m × n) time.
Report an error in this question
Algorithm Design TechniquesMedium
Q16. How does memoization improve the Fibonacci computation?
- A.It reduces time from O(2^n) to O(n) by caching✓ Correct
- B.It makes the computation run in O(log n) time
- C.It does not improve it at all
- D.It makes the computation run in O(1) time
Explanation
Memoization caches the result of each Fibonacci number, ensuring each is computed only once, reducing time from O(2^n) to O(n).
Report an error in this question
Algorithm Design TechniquesMedium
Q17. What is the difference between top-down and bottom-up dynamic programming?
- A.Top-down is always faster in practice than the bottom-up approach overall
- B.Top-down uses recursion with memoization; bottom-up uses tabulation✓ Correct
- C.Bottom-up always uses significantly more memory than the top-down approach
- D.They are exactly the same fundamental approach overall
Explanation
Top-down (memoization) uses recursion and caches results. Bottom-up (tabulation) iteratively fills a table from smallest subproblems upward.
Report an error in this question
Algorithm Design TechniquesMedium
Q18. What is the N-Queens problem?
- A.A graph traversal problem with N vertices
- B.Sorting N queens by their rank and position
- C.Finding N queens in a given dataset collection
- D.Placing N queens so no two attack each other✓ Correct
Explanation
The N-Queens problem asks to place N queens on an N×N chessboard so that no two queens share the same row, column, or diagonal. It is typically solved using backtracking.
Report an error in this question
Algorithm Design TechniquesHard
Q19. What is a randomized algorithm?
- A.An algorithm with random bugs in code
- B.An algorithm using random numbers in its decisions✓ Correct
- C.An algorithm that shuffles input before sorting
- D.An algorithm that produces random wrong output
Explanation
A randomized algorithm uses random numbers in its logic, often achieving good expected performance (e.g., randomized quicksort, randomized primality testing).
Report an error in this question
Algorithm Design TechniquesHard
Q20. What is the meet-in-the-middle technique?
- A.A two-pointer approach for sorted arrays
- B.A median-finding technique using partitioning
- C.Dividing the array in half for sorting
- D.Splitting input in half and combining to reduce complexity✓ Correct
Explanation
Meet-in-the-middle splits the input in half, independently computes results for each half, and combines them. It reduces O(2^n) to O(2^(n/2)) for problems like subset sum.
Report an error in this question
Algorithm Design TechniquesHard
Q21. What is the edit distance (Levenshtein distance) problem?
- A.The minimum single-character edits between two strings✓ Correct
- B.The difference in the lengths of two strings
- C.The number of common characters in two strings
- D.The distance between two arrays in memory
Explanation
Edit distance measures the minimum number of insertions, deletions, and substitutions needed to transform one string into another. Solved using DP in O(m × n).
Report an error in this question
Algorithm Design TechniquesHard
Q22. What is branch and bound?
- A.A hashing technique for collision resolution
- B.A type of comparison-based sorting method
- C.An optimization technique pruning suboptimal branches✓ Correct
- D.A graph traversal method for shortest paths
Explanation
Branch and bound explores a tree of solutions, using bounds to prune branches that cannot lead to a better solution than the best found so far.
Report an error in this question
Algorithm Design TechniquesHard
Q23. What is the difference between the 0/1 knapsack and fractional knapsack?
- A.0/1 uses greedy approach; fractional uses DP approach
- B.Fractional knapsack is computationally harder overall
- C.They are exactly the same problem formulation
- D.0/1 requires whole items (DP); fractional allows fractions (greedy)✓ Correct
Explanation
In 0/1 knapsack, items must be taken whole (solved by DP). In fractional knapsack, items can be divided (solved greedily by value-to-weight ratio).
Report an error in this question
Algorithm Design TechniquesHard
Q24. What is the subset sum problem?
- A.Finding the sum of all array elements
- B.Summing consecutive elements in an array
- C.Finding the maximum valued subset overall
- D.Determining if a subset sums to a target value✓ Correct
Explanation
The subset sum problem asks whether any subset of a given set of integers sums to a target value. It is NP-complete but solvable in pseudo-polynomial time using DP.
Report an error in this question
Algorithm Design TechniquesMedium
Q25. What is Huffman coding an example of?
- A.Greedy algorithm✓ Correct
- B.Backtracking
- C.Dynamic programming
- D.Divide and conquer
Explanation
Huffman coding is a greedy algorithm for constructing optimal prefix-free codes, always merging the two least frequent nodes first.
Report an error in this question
Algorithm Design TechniquesHard
Q26. What is the time complexity of solving TSP using dynamic programming (Held-Karp)?
- A.O(n^3)
- B.O(n^2 × 2^n)✓ Correct
- C.O(n!)
- D.O(2^n)
Explanation
The Held-Karp DP algorithm solves TSP in O(n^2 × 2^n) time, much better than the brute-force O(n!) approach.
Report an error in this question
Algorithm Design TechniquesMedium
Q27. What is the Longest Increasing Subsequence (LIS) problem's time complexity with DP?
- A.O(n)
- B.O(2^n)
- C.O(n log n)
- D.O(n^2)✓ Correct
Explanation
The standard DP solution for LIS runs in O(n^2) time. An optimized approach using binary search achieves O(n log n).
Report an error in this question
Algorithm Design TechniquesHard
Q28. What is the Traveling Salesman Problem (TSP)?
- A.Finding the shortest path between two specific cities
- B.Finding the fastest route avoiding all toll roads
- C.Finding minimum cost Hamiltonian cycle visiting all cities✓ Correct
- D.A minimum spanning tree problem for city networks
Explanation
TSP asks for the shortest possible route that visits each city exactly once and returns to the starting city. It is NP-hard.
Report an error in this question
Algorithm Design TechniquesHard
Q29. What is an approximation algorithm?
- A.An algorithm that gives approximate time complexity
- B.An algorithm finding near-optimal solutions in polynomial time✓ Correct
- C.An imprecise algorithm with unreliable output
- D.An algorithm that estimates the input data size
Explanation
An approximation algorithm finds solutions within a provable factor of the optimal for NP-hard problems, running in polynomial time.
Report an error in this question
Algorithm Design TechniquesHard
Q30. What is the matrix chain multiplication problem's time complexity using DP?
- A.O(n^3)✓ Correct
- B.O(n!)
- C.O(2^n)
- D.O(n^2)
Explanation
The matrix chain multiplication DP solution has O(n^3) time complexity and O(n^2) space, where n is the number of matrices.
Report an error in this question