0% found this document useful (0 votes)
13 views

Analysis of Algorithm Viva QA

The document provides a comprehensive overview of algorithm analysis, covering key concepts such as time and space complexity, Big-O notation, and classifications of problems like P, NP, NP-Complete, and NP-Hard. It also discusses various algorithmic techniques including Divide and Conquer, Greedy methods, Dynamic Programming, Backtracking, and Branch & Bound, along with specific algorithms like Dijkstra's, Bellman-Ford, and KMP. Additionally, it includes time complexities for sorting and searching algorithms, as well as problem-solving strategies like the 0/1 Knapsack and the Traveling Salesman Problem.

Uploaded by

Darsh Jilka
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)
13 views

Analysis of Algorithm Viva QA

The document provides a comprehensive overview of algorithm analysis, covering key concepts such as time and space complexity, Big-O notation, and classifications of problems like P, NP, NP-Complete, and NP-Hard. It also discusses various algorithmic techniques including Divide and Conquer, Greedy methods, Dynamic Programming, Backtracking, and Branch & Bound, along with specific algorithms like Dijkstra's, Bellman-Ford, and KMP. Additionally, it includes time complexities for sorting and searching algorithms, as well as problem-solving strategies like the 0/1 Knapsack and the Traveling Salesman Problem.

Uploaded by

Darsh Jilka
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/ 4

Viva Questions & Answers: Analysis of Algorithm

Module 1: Introduction

Q: What is algorithm analysis?

A: It is the process of determining the computational complexity of algorithms.

Q: What is time and space complexity?

A: Time complexity is time taken as a function of input size. Space complexity is the memory used.

Q: Define Big-O, Omega, and Theta notation.

A: Big-O (O): Worst-case; Omega (Omega): Best-case; Theta (Theta): Tight bound.

Q: What is the difference between P, NP, NP-Complete, and NP-Hard?

A: P: Solvable in polynomial time.

NP: Verifiable in polynomial time.

NP-Complete: Hardest problems in NP.

NP-Hard: At least as hard as NP-Complete.

Q: Time complexity of Selection and Insertion Sort?

A: Selection: O(n²)

Insertion: Best O(n), Worst/Average O(n²)

Q: What is a recurrence relation?

A: An equation that recursively defines a sequence.

Q: Methods to solve recurrences?

A: Substitution, Recursion Tree, and Master Method.

Module 2: Divide and Conquer

Q: What is Divide and Conquer?

A: A technique dividing a problem into subproblems, solving recursively, then combining.

Q: Time complexity of Merge and Quick Sort?


Viva Questions & Answers: Analysis of Algorithm

A: Merge Sort: O(n log n), Quick Sort: Avg O(n log n), Worst O(n²)

Q: Finding Min and Max using divide and conquer?

A: By comparing in pairs and reducing comparisons to 3n/2 - 2.

Q: Time complexity of Binary Search?

A: O(log n)

Module 3: Greedy Method

Q: What is a greedy algorithm?

A: It makes locally optimal choices hoping for a global optimum.

Q: Explain Dijkstra's algorithm.

A: Finds shortest path from source to all nodes with non-negative weights.

Q: Difference between 0/1 and Fractional Knapsack?

A: 0/1: Items can't be split (DP).

Fractional: Items can be split (Greedy).

Q: What is job sequencing with deadlines?

A: Schedule jobs to maximize profit before deadlines.

Q: Difference between Kruskal's and Prim's?

A: Kruskal: Edge-based.

Prim: Vertex-based.

Module 4: Dynamic Programming

Q: What is dynamic programming?

A: Solving subproblems, storing results, and reusing them.

Q: Greedy vs Dynamic Programming?


Viva Questions & Answers: Analysis of Algorithm

A: Greedy: local decisions.

DP: uses memory for global solution.

Q: Explain Bellman-Ford algorithm.

A: Finds shortest path from source with negative weights allowed.

Q: What is Floyd-Warshall algorithm?

A: All-pairs shortest path using DP.

Q: Explain 0/1 Knapsack.

A: Maximize profit with indivisible items and weight limit.

Q: What is LCS?

A: Longest subsequence common in two strings.

Q: Describe Assembly-line Scheduling.

A: Optimizes assembly time considering transfer time.

Q: What is TSP?

A: Finds shortest cycle to visit all cities exactly once and return.

Module 5: Backtracking and Branch & Bound

Q: What is backtracking?

A: Explores all solutions, backtracks on invalid paths.

Q: Explain N-Queen problem.

A: Place N queens with no threat on N×N board.

Q: Describe Sum of Subsets.

A: Find subsets whose sum is equal to a target.


Viva Questions & Answers: Analysis of Algorithm

Q: What is Graph coloring?

A: Assign colors so adjacent nodes have different colors.

Q: What is Branch and Bound?

A: Optimization by pruning unpromising candidates.

Q: TSP using Branch and Bound?

A: Use cost matrix and bounds to prune paths.

Q: Explain 15-Puzzle problem.

A: Sliding puzzle solved using heuristics and bounding.

Module 6: String Matching Algorithms

Q: Naive string-matching algorithm?

A: Compares pattern to every substring.

Q: Describe Rabin-Karp algorithm.

A: Uses hash values to compare substrings.

Q: What is KMP algorithm?

A: Uses prefix table to avoid unnecessary checks.

Q: Time complexities?

A: Naive: O(nm)

Rabin-Karp: Avg O(n+m), Worst O(nm)

KMP: O(n+m)

You might also like