Retrieving academic index assets...
Makaut
HomePYQsTests
Pricing
Sign Up
Makaut

The premier academic archive for MAKAUT students, providing curated previous year questions, solutions, and official syllabus resources.

Get the Mobile App
GET IT ONGoogle Play
Download on theApp Store
Download from Indus App Store
Platform
  • Home
  • PYQs
  • Question Papers
  • Viva Questions
  • Important Questions
  • Syllabus
  • Academic Tools
  • Pricing
  • Blog
Guidelines
  • Disclaimer
  • Community Guidelines
Company
  • About
  • Contact
  • FAQ
Legal
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Cookie Policy
  • Subscription Policy
© 2026 MAKAUT Study Dev Hub. All rights reserved.
Platform version: v1.0.0
Viva Questions/PCC-CS404
Semester 4PCC-CS404

Design and Analysis of Algorithms (PCC-CS404) Viva Questions and Answers

51 Questions•11 min read
Prepared from MAKAUT past-year question papers.
Practice Mode:All answers visible
Jump to Topic
Greedy Algorithms (10)Asymptotic Notations (8)Searching (2)Dynamic Programming (4)Backtracking (2)Graph Algorithms (7)NP-Completeness (5)Network Flow (4)Sorting (4)Randomized Algorithms (1)Algorithm Fundamentals (2)Recurrence Relations (1)Approximation Algorithms (1)

Greedy Algorithms

10 questions
Q1.EASY

What is the time complexity of the Knapsack algorithm using the Greedy method (fractional knapsack)?

The greedy fractional knapsack algorithm sorts items by value/weight ratio, which takes O(nlog⁡n)O(n \log n)O(nlogn) time, and then fills the knapsack in O(n)O(n)O(n) time. So the overall time complexity is O(nlog⁡n)O(n \log n)O(nlogn).
Q7.MEDIUM

What is the time complexity of Job Sequencing with Deadline using the greedy method?

The greedy algorithm sorts jobs by profit in O(nlog⁡n)O(n \log n)O(nlogn) time and then schedules them using a disjoint-set or array, taking O(nα(n))O(n \alpha(n))O(nα(n)) or O(n2)O(n^2)O(n2) depending on implementation. Overall, it is O(nlog⁡n)O(n \log n)O(nlogn) with efficient scheduling.
Q10.MEDIUM

What is the appropriate data structure for Prim's Minimum Spanning Tree algorithm?

A priority queue (min-heap) is typically used to efficiently extract the minimum-weight edge connecting the tree to a new vertex. This gives a time complexity of O(Elog⁡V)O(E \log V)O(ElogV) with a binary heap.
Q13.EASY

Fractional knapsack problem is solved most efficiently by which algorithm design technique?

The fractional knapsack problem is solved efficiently by the greedy method. We sort items by value/weight ratio and take as much as possible of the highest ratio item first.
Q18.MEDIUM

State True or False: The 0-1 Knapsack problem can be solved using a greedy algorithm.

False. The 0-1 knapsack problem cannot be solved optimally by a greedy algorithm; it requires dynamic programming. Greedy works for the fractional knapsack but not for 0-1 because items cannot be split.
Q20.MEDIUM

Given items as {value, weight} pairs {(40,20), (30,10), (20,5)} and knapsack capacity 20, find the maximum value for fractional knapsack.

Compute value/weight ratios: 40/20=2, 30/10=3, 20/5=4. Greedy picks highest ratio first: take item3 (value 20, weight 5), then item2 (value 30, weight 10), remaining capacity 5. Take 5/20 of item1: value 10. Total value = 20+30+10=60.
Q24.MEDIUM

For a set of 5 items and knapsack capacity 10 kg, how do you find maximum profit if fractional amounts are allowed?

Use the greedy fractional knapsack approach: compute value/weight ratio for each item, sort in descending order, and take items fully until capacity is reached, then take a fraction of the next item. This yields the optimal profit.
Q32.HARD

Using greedy method, find an optimal solution for job sequencing with deadlines: n=4, profits=(100,10,5,27), deadlines=(2,1,2,1).

Sort jobs by profit: (100,d=2), (27,d=1), (10,d=1), (5,d=2). Schedule: job1 at slot1, job4 at slot2? Wait, job4 deadline1 so slot1 taken; job1 slot2. Then job2 deadline1 slot1 taken, job3 deadline2 slot2 taken. Optimal profit = 100+27=127.
Q43.MEDIUM

What is the time complexity of Prim's algorithm using the greedy method? (Number of vertices = V)

With a binary heap, Prim's algorithm runs in O(Elog⁡V)O(E \log V)O(ElogV) time, where EEE is the number of edges. With an adjacency matrix, it is O(V2)O(V^2)O(V2).
Q45.MEDIUM

What is the time complexity of Kruskal's algorithm using the greedy method? (Number of edges = E)

Kruskal's algorithm sorts edges in O(Elog⁡E)O(E \log E)O(ElogE) time and uses union-find for cycle detection, taking nearly O(Eα(V))O(E \alpha(V))O(Eα(V)). Overall time complexity is O(Elog⁡E)O(E \log E)O(ElogE) or O(Elog⁡V)O(E \log V)O(ElogV).

Asymptotic Notations

8 questions
Q2.EASY

State True or False: O(log n) > O(n). Justify.

False. Asymptotically, O(log⁡n)O(\log n)O(logn) grows much slower than O(n)O(n)O(n). For large nnn, log⁡n<n\log n < nlogn<n, so O(log⁡n)O(\log n)O(logn) is a tighter upper bound than O(n)O(n)O(n).
Q11.EASY

What is represented by the asymptotic notation O(1)?

O(1)O(1)O(1) represents constant time complexity, meaning the algorithm takes a fixed amount of time regardless of input size. For example, accessing an array element by index is O(1)O(1)O(1).
Q12.EASY

The notation Ω(n) is the formal way to express which bound of an algorithm's running time?

Ω(n)\Omega(n)Ω(n) expresses the lower bound (best-case) of an algorithm's running time. It means the algorithm takes at least a constant times nnn time for large nnn.
Q30.MEDIUM

Discuss the different asymptotic notations and their importance.

Big-O (OOO) gives upper bound, Big-Omega (Ω\OmegaΩ) gives lower bound, and Big-Theta (Θ\ThetaΘ) gives tight bound. Little-o (ooo) and little-omega (ω\omegaω) give strict bounds. They are important for comparing algorithm efficiency independent of machine details.
Q40.EASY

State True or False: O(2^n) > O(n^2) for n > 3.

True. For n>3n > 3n>3, 2n2^n2n grows much faster than n2n^2n2. Asymptotically, O(2n)O(2^n)O(2n) is a looser upper bound than O(n2)O(n^2)O(n2).
Q42.EASY

State True or False: If f(n)=2n^3+4n^2, then f(n) = O(n^3).

True. The highest-order term is 2n32n^32n3, so f(n)=O(n3)f(n) = O(n^3)f(n)=O(n3). The lower-order term 4n24n^24n2 is dominated for large nnn.
Q50.MEDIUM

Define Little oh (o) notation.

Little oh notation o(g(n))o(g(n))o(g(n)) represents a set of functions f(n)f(n)f(n) such that f(n)f(n)f(n) grows strictly slower than g(n)g(n)g(n). Formally, for any positive constant ccc, there exists n0n_0n0​ such that 0≤f(n)<c⋅g(n)0 \le f(n) < c \cdot g(n)0≤f(n)<c⋅g(n) for all n≥n0n \ge n_0n≥n0​.
Q51.MEDIUM

Prove that log n! = O(n log n).

Using Stirling's approximation, log⁡(n!)=Θ(nlog⁡n)\log(n!) = \Theta(n \log n)log(n!)=Θ(nlogn). Alternatively, n!≤nnn! \le n^nn!≤nn, so log⁡(n!)≤nlog⁡n\log(n!) \le n \log nlog(n!)≤nlogn, hence log⁡(n!)=O(nlog⁡n)\log(n!) = O(n \log n)log(n!)=O(nlogn).

Searching

2 questions
Q3.EASY

What is the best-case time complexity of binary search?

The best case occurs when the target element is at the middle of the array. Then only one comparison is needed, so the best-case time complexity is O(1)O(1)O(1).
Q44.EASY

What is the best-case time complexity of linear search?

The best case occurs when the target element is the first element checked. Then only one comparison is needed, so the best-case time complexity is O(1)O(1)O(1).

Dynamic Programming

4 questions
Q4.EASY

What is the time complexity of Floyd's algorithm (Floyd-Warshall)?

Floyd-Warshall uses three nested loops over all vertices, so its time complexity is O(V3)O(V^3)O(V3), where VVV is the number of vertices.
Q23.MEDIUM

Write the Floyd-Warshall algorithm for all-pairs shortest path. What is its time complexity?

Initialize distance matrix with edge weights. For each intermediate vertex kkk, update
d[i][j]=min⁡(d[i][j],d[i][k]+d[k][j])d[i][j] = \min(d[i][j], d[i][k]+d[k][j])d[i][j]=min(d[i][j],d[i][k]+d[k][j])
for all i,ji,ji,j. Time complexity is O(V3)O(V^3)O(V3).
Q26.MEDIUM

Find the minimum number of multiplications for matrix chain multiplication: A(10x20) * B(20x30) * C(30x40).

Compute costs: (AB)C: 10*20*30 + 10*30*40 = 6000+12000=18000. A(BC): 20*30*40 + 10*20*40 = 24000+8000=32000. Minimum is 18000 multiplications.
Q28.MEDIUM

Discuss the advantages and drawbacks of Dynamic Programming.

Advantages: solves overlapping subproblems efficiently, gives optimal solutions, and avoids recomputation via memoization. Drawbacks: requires optimal substructure, may use large memory for tables, and can be slower than greedy for some problems.

Backtracking

2 questions
Q5.EASY

Backtracking follows which traversal technique?

Backtracking follows Depth-First Search (DFS) traversal. It explores a path as far as possible and then backtracks when a dead end is reached.
Q16.MEDIUM

How many solutions are there for the 8-queens problem on an 8x8 board?

There are 92 distinct solutions to the 8-queens problem. If we consider solutions that are reflections or rotations of each other as the same, there are 12 fundamental solutions.

Graph Algorithms

7 questions
Q6.EASY

Define a spanning tree.

A spanning tree of a connected undirected graph is a subgraph that is a tree and includes all the vertices of the graph. It has exactly V−1V-1V−1 edges and no cycles.
Q14.EASY

What is the appropriate data structure for Depth First Search (DFS)?

DFS uses a stack (either explicitly or via recursion) to keep track of vertices to visit next. This allows backtracking to the most recently discovered vertex.
Q19.MEDIUM

Which algorithm is used to solve the single-source shortest path problem in a graph with negative edge weights?

The Bellman-Ford algorithm is used when negative edge weights are present. It can detect negative cycles and runs in O(VE)O(VE)O(VE) time.
Q21.MEDIUM

What are the differences between Dijkstra's algorithm and Bellman-Ford algorithm? Compare their time complexities.

Dijkstra's algorithm works only for non-negative edge weights and uses a priority queue, giving O((V+E)log⁡V)O((V+E)\log V)O((V+E)logV) time. Bellman-Ford handles negative weights, detects negative cycles, and runs in O(VE)O(VE)O(VE) time.
Q27.MEDIUM

Write the algorithm for single-source shortest path allowing negative edge weights.

Use Bellman-Ford: initialize distances to infinity except source=0. Relax all edges V−1V-1V−1 times: for each edge (u,v,w)(u,v,w)(u,v,w), if d[v]>d[u]+wd[v] > d[u]+wd[v]>d[u]+w, update d[v]d[v]d[v]. Then check for negative cycles by one more relaxation; if any update occurs, negative cycle exists.
Q41.EASY

Topological sorting is performed on which type of graph?

Topological sorting is performed on a Directed Acyclic Graph (DAG). It gives a linear ordering of vertices such that for every directed edge u→vu \to vu→v, uuu comes before vvv.
Q46.EASY

DFS uses which data structure?

DFS uses a stack (either explicitly or via recursion) to keep track of vertices to visit next. This allows backtracking to the most recently discovered vertex.

NP-Completeness

5 questions
Q8.MEDIUM

State Cook's Theorem.

Cook's Theorem states that the Boolean satisfiability problem (SAT) is NP-complete. It was the first problem proven to be NP-complete, showing that SAT is in NP and every problem in NP reduces to it in polynomial time.
Q9.EASY

Define a clique with an example.

A clique in an undirected graph is a subset of vertices such that every two vertices in the subset are adjacent. For example, in a triangle graph with vertices A, B, C and edges AB, BC, CA, the set {A, B, C} is a clique of size 3.
Q33.MEDIUM

Write and explain the classes P, NP, NP-hard, and NP-complete.

P: problems solvable in polynomial time. NP: problems verifiable in polynomial time. NP-hard: problems at least as hard as any NP problem (not necessarily in NP). NP-complete: problems in NP and NP-hard. If any NP-complete problem is in P, then P=NP.
Q34.MEDIUM

What is reducibility?

Reducibility is a way to show that one problem is at least as hard as another. If problem A reduces to problem B in polynomial time, then a solution to B can solve A, so B is at least as hard as A.
Q35.HARD

If any NP-complete problem can be solved in polynomial time, then P=NP. Explain.

Since every NP problem reduces to an NP-complete problem in polynomial time, a polynomial-time solution to one NP-complete problem would give a polynomial-time solution to all NP problems. Thus P would equal NP.

Network Flow

4 questions
Q15.EASY

Which algorithm is used to solve the maximum flow problem?

The Ford-Fulkerson algorithm (and its variants like Edmonds-Karp) is used to solve the maximum flow problem. It repeatedly finds augmenting paths in the residual network until no more exist.
Q36.MEDIUM

What is a flow network? What are the constraints on flow?

A flow network is a directed graph with capacities on edges and a source and sink. Constraints: capacity constraint (0≤f(u,v)≤c(u,v)0 \le f(u,v) \le c(u,v)0≤f(u,v)≤c(u,v)) and flow conservation (inflow equals outflow for all vertices except source and sink).
Q37.MEDIUM

What is an augmenting path in a flow network? How is residual capacity calculated?

An augmenting path is a path from source to sink in the residual graph with positive residual capacity. Residual capacity of an edge is c(u,v)−f(u,v)c(u,v) - f(u,v)c(u,v)−f(u,v) (forward) or f(v,u)f(v,u)f(v,u) (backward). The bottleneck capacity of the path is the minimum residual capacity along it.
Q38.MEDIUM

Write the Ford-Fulkerson algorithm for maximum flow.

Initialize flow to 0. While there exists an augmenting path from source to sink in the residual graph, find the bottleneck capacity and augment flow along the path. Update residual capacities. When no augmenting path exists, the flow is maximum.

Sorting

4 questions
Q17.EASY

What is the time complexity of Heap sort with n items?

Heap sort has a time complexity of O(nlog⁡n)O(n \log n)O(nlogn) in all cases (best, average, worst). Building the heap takes O(n)O(n)O(n) and each of the nnn extractions takes O(log⁡n)O(\log n)O(logn).
Q22.MEDIUM

Analyze the time complexity of quick sort for best and worst cases using recurrence relations.

Best case: pivot splits array evenly, T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n), giving O(nlog⁡n)O(n \log n)O(nlogn). Worst case: pivot is always extreme, T(n)=T(n−1)+O(n)T(n)=T(n-1)+O(n)T(n)=T(n−1)+O(n), giving O(n2)O(n^2)O(n2).
Q48.EASY

What is the worst-case time complexity of Heap sort?

Heap sort has a worst-case time complexity of O(nlog⁡n)O(n \log n)O(nlogn). Building the heap takes O(n)O(n)O(n) and each of the nnn extractions takes O(log⁡n)O(\log n)O(logn).
Q49.EASY

What is the space complexity of Merge sort?

Merge sort requires O(n)O(n)O(n) auxiliary space for merging the divided arrays. The recursion stack also takes O(log⁡n)O(\log n)O(logn) space, but the dominant term is O(n)O(n)O(n).

Randomized Algorithms

1 question
Q25.MEDIUM

What is a randomized algorithm? Give a short note.

A randomized algorithm uses random numbers at some steps to influence its execution. It can be Las Vegas (always correct, random time) or Monte Carlo (random correctness, fixed time). Examples include randomized quicksort and Miller-Rabin primality test.

Algorithm Fundamentals

2 questions
Q29.EASY

What are the features of any algorithm?

An algorithm must have: finiteness (terminates), definiteness (clear steps), input, output, and effectiveness (each step is basic and feasible). It should also be correct and efficient.
Q47.EASY

Give two examples of optimization problems.

Two examples are the Traveling Salesman Problem (find shortest tour visiting all cities) and the Knapsack Problem (maximize value within weight capacity). Both aim to find the best solution among many feasible ones.

Recurrence Relations

1 question
Q31.MEDIUM

Write the recurrence relation for Towers of Hanoi and solve it.

Recurrence: T(n)=2T(n−1)+1T(n) = 2T(n-1) + 1T(n)=2T(n−1)+1, with T(1)=1T(1)=1T(1)=1. Solving by substitution: T(n)=2n−1T(n) = 2^n - 1T(n)=2n−1, so time complexity is O(2n)O(2^n)O(2n).

Approximation Algorithms

1 question
Q39.MEDIUM

State True or False: Approximation ratio is always less than or equal to 1.

False. The approximation ratio is typically defined as the ratio of the algorithm's solution to the optimal solution, which is ≥1\ge 1≥1 for minimization problems (or ≤1\le 1≤1 for maximization). It is not always ≤1\le 1≤1.

Frequently Asked Viva Voce Questions

High-priority theoretical and lab evaluation questions typically tested by MAKAUT external examiners.

Related Course Resources

SYLLABUSDesign and Analysis of Algorithms Syllabus & Handouts
Open resource
PYQSemester 4 PYQ Papers
Open resource

On This Page

13 Units
Greedy Algorithms10
Asymptotic Notations8
Searching2
Dynamic Programming4
Backtracking2
Graph Algorithms7
NP-Completeness5
Network Flow4
Sorting4
Randomized Algorithms1
Algorithm Fundamentals2
Recurrence Relations1
Approximation Algorithms1