0% found this document useful (0 votes)
9 views3 pages

Aoa Viva

The document provides an overview of key concepts in algorithm analysis, including time complexity, space complexity, and various complexity classes such as P, NP, NP-Complete, and NP-Hard. It also explains several algorithms and techniques, including sorting algorithms (Quick sort, Merge sort), shortest path algorithms (Dijkstra's, Bellman-Ford, Floyd-Warshall), and optimization methods (greedy algorithms, dynamic programming, backtracking). Additionally, it covers specific problems like the knapsack problem and the Traveling Salesman Problem, along with string matching techniques.
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)
9 views3 pages

Aoa Viva

The document provides an overview of key concepts in algorithm analysis, including time complexity, space complexity, and various complexity classes such as P, NP, NP-Complete, and NP-Hard. It also explains several algorithms and techniques, including sorting algorithms (Quick sort, Merge sort), shortest path algorithms (Dijkstra's, Bellman-Ford, Floyd-Warshall), and optimization methods (greedy algorithms, dynamic programming, backtracking). Additionally, it covers specific problems like the knapsack problem and the Traveling Salesman Problem, along with string matching techniques.
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/ 3

1. What is time complexity?

Time complexity represents the amount of time an algorithm takes to run as a function of the
input size, usually denoted as n. It helps in analyzing the efficiency of an algorithm.

2. What is space complexity?


Space complexity refers to the total amount of memory used by an algorithm, including input
values, auxiliary space, and function call stack during execution.

3. Types of complexity classes:


The main classes are:

P: Problems solvable in polynomial time.

NP: Problems verifiable in polynomial time.

NP-Complete: Problems in NP that are as hard as any other problem in NP.

NP-Hard: Problems at least as hard as NP-Complete, not necessarily in NP.

4. What is P, NP, and NP-Hard classes?

P: Problems solvable in polynomial time.

NP: Problems verifiable in polynomial time.

NP-Hard: Problems for which no polynomial-time solution is known, and solving them would
solve all NP problems.

5. What is NP-Complete class?


A problem is NP-Complete if it is in NP and every problem in NP can be reduced to it in
polynomial time.

6. What is Omega notation?


Omega (Ω) notation provides a lower bound on the running time of an algorithm — the
best-case scenario.

7. What is Big O?
Big O notation provides an upper bound on the time complexity — the worst-case scenario.

8. What is Theta notation?


Theta (Θ) notation gives a tight bound — when an algorithm’s best and worst-case complexities
are the same.
9. What is Bellman-Ford algorithm?
It is a single-source shortest path algorithm that handles negative weights and detects negative
cycles.

10. What is Floyd-Warshall algorithm?


It is an all-pairs shortest path algorithm using dynamic programming, suitable for dense graphs.

11. How to divide in Quick sort algorithm?


Quick sort uses a pivot to partition the array into two subarrays: elements less than the pivot
and elements greater than the pivot.

12. How Quick sort works?


It recursively partitions the array using a pivot and then sorts the subarrays independently.

13. How Merge sort works?


Merge sort divides the array into halves, recursively sorts them, and merges the sorted halves.

14. What is the greedy method?


Greedy algorithms make locally optimal choices at each step with the hope of finding a global
optimum.

15. What is Dijkstra's algorithm?


It is a single-source shortest path algorithm for non-negative edge-weighted graphs using a
priority queue.

16. What is fractional knapsack problem?


Items can be broken into fractions; the goal is to maximize profit within a weight capacity using a
greedy approach.

17. What is 0/1 knapsack problem?


Items cannot be broken; either take the whole item or leave it. It’s solved using dynamic
programming.

18. What is Kruskal's algorithm?


A greedy algorithm that finds a minimum spanning tree by adding the next smallest edge that
doesn’t form a cycle.

19. What is Prim's algorithm?


It also finds a minimum spanning tree but starts from a node and grows the tree by adding the
smallest edge connecting the tree to an unvisited vertex.

20. What is dynamic programming approach?


It solves problems by breaking them into overlapping subproblems, solving each once, and
storing the results.

21. How multi-stage graph works?


A graph is divided into multiple stages, and the shortest path from source to destination is
computed using dynamic programming.

22. How longest common subsequence problem works?


It finds the longest sequence present in both strings using dynamic programming by building a
matrix of solutions to subproblems.

23. What is backtracking?


A technique for solving problems incrementally and abandoning solutions (“backtracking”) when
they fail to satisfy constraints.

24. What is branch and bound?


An optimization technique where branches of the decision tree are explored, and bounds are
used to eliminate paths that can’t produce better solutions.

25. How salesman algorithm works (Traveling Salesman Problem)?


It aims to find the shortest possible route that visits each city once and returns to the origin.
Exact solutions use dynamic programming or branch and bound; heuristics give approximate
solutions.

26. How many types of string matching?


Main types include:

Naive string matching

Rabin-Karp

Knuth-Morris-Pratt (KMP)

Boyer-Moore

Finite automaton-based matching

You might also like