0% found this document useful (0 votes)
36 views4 pages

ADA Viva Questions Unit 3,4,5

The document discusses various algorithms including divide and conquer, dynamic programming, and greedy algorithms. It provides definitions and examples of recurrence equations, recursive algorithms, binary search, merge sort, quick sort, optimal solutions, the principle of optimality, dynamic programming, knapsack problem, and greedy algorithms.

Uploaded by

Yash Patel
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)
36 views4 pages

ADA Viva Questions Unit 3,4,5

The document discusses various algorithms including divide and conquer, dynamic programming, and greedy algorithms. It provides definitions and examples of recurrence equations, recursive algorithms, binary search, merge sort, quick sort, optimal solutions, the principle of optimality, dynamic programming, knapsack problem, and greedy algorithms.

Uploaded by

Yash Patel
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

UNIT NO-3: Divide and Conquer Algorithm

1. Define : Recurrence Equations.


Recurrence Equation is an equation that defines a sequence
recursively. It is normally in following form-
T(n)=T(n-1)+n for n>0
T(0)=0

2. What is recursive algorithm?


An algorithm is said to be recursive if the same algorithm is
invoked in the body.

3. Write an algorithm using recursive function to find sum of n


numbers.
Algorithm sum(n)
total=0;
If(n>0) then
total=total+sum(n-1);
return total;

4. Which searching algorithm required Sorted list of elements?


Binary Search Algorithm

5. The worst-case time complexity of Merge Sort is________.


Ans.O(n logn)
6. The worst-case time complexity of Quick Sort is________.
Ans.O(n2 )

UNIT NO-4 : Dynamic Programming

1. What is meant by an optimal solution for a given problem?


It has to be the best choice among all feasible solution available
on that step.

2. Write Principal of Optimality


It states that in an optimal sequence of decisions or choices , each
subsequent must also be optimal.

3. What is a dynamic programming?


It is a technique for solving problems with overlapping
subproblems. In this method each sub problem is solved only once.
The result of each sub problem is recorded in a table from which we
can obtain a solution to the original problem

3. What is knapsack problem?


If there are n items with weight w1,w2,….wn and values
v1,v2,…vn and capacity of knapsack to be W , then find the most
valuable subset of the items that fit into the knapsack
4. Which problems are solved using Dynamic programming?
1. Calculating Binomial coefficient
2. Making change problem
3. Assembly line scheduling
4. Knapsack problem
5. Shortest path
6. Matrix chain multiplication

5. Write the objective of making change problem


The making-change problem addresses the question of finding
the minimum number of coins (of certain denominations) that add
up to a given amount of money.

UNIT NO-5 : Greedy Algorithm

1. What is the basic nature of greedy strategy?


A greedy algorithm always makes the choice that seemsto be
the best at that moment. This means that it makes a locally-optimal
choice in the hope that this choice will lead to a globally-optimal
solution.it is a top down approach

2. Define: Optimal Solution


It has to be the best choice among all feasible solution available
on that step

3. Define: Feasible solution.


Any subset that satisfies problems constraint, is called feasible
solution.
4. Define Minimum Spanning Tree.
A minimum spanning tree is a subset of the edges of a
connected, edge-weighted undirected graph that connects all the
vertices together, without any cycles and with the minimum possible
total edge weight

5. what is Huffman code?


This algorithm is basically a ciding technique for encoding data
such an encoded data. Such an encoded data is used in data
compression techniques

6. what is greedy choice property?


Optimal solution to a problem is found by choosing best
solution at each step without reconsidering choice made at previous
step.

You might also like