0% found this document useful (0 votes)
145 views8 pages

DAA - Questions BANK

The document discusses an exam for the subject Design and Analysis of Algorithms. It contains multiple choice and short answer questions testing concepts like time complexity, recursion, sorting algorithms, graph algorithms, and computational complexity.

Uploaded by

killerpreet003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views8 pages

DAA - Questions BANK

The document discusses an exam for the subject Design and Analysis of Algorithms. It contains multiple choice and short answer questions testing concepts like time complexity, recursion, sorting algorithms, graph algorithms, and computational complexity.

Uploaded by

killerpreet003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

B Tech 2nd year

Subject: Design and Analysis of Algorithm


Subject Code: CSC408

1 mark question (20)


1. Which one of the following helps in calculating the longest amount of time taken for the completion of the
algorithm?
a. Theta notation
b. Big-Oh notation
c. Omega notation
d. Time complexity
2. For converting recursive algorithm to non-recursive algorithm, store the values of all ___ parameters in
the stack.
a. Negative
b. Global
c. Pass by reference
d. Pass by value
3. The recursive versions of binary search use a ___ structure.
a. Branch and bound
b. Dynamic programming
c. Divide and conquer
d. Simple recursive
4. Which method is practical to perform a single search in an unsorted list of elements?
a. Sequential search
b. Bubble sort
c. Horspool’s method of string matching
d. Brute force method of string matching
5. Which algorithm finds the solution for the single-source shortest path problem for a tree?
a. Prim’s
b. Dijkstra’s
c. Kruskal’s
d. Huffman code
6. ___ is an optimization technique for particular classes of backtracking algorithms that repeatedly solve
sub-problems.
a. Decrease and conquer
b. Dynamic programming
c. Branch and bound
d. Divide and Conquer
7. ___ is the technique by which we make a function perform faster by trading space for time.
a. Divide and conquer
b. Greedy
c. Memoization
d. Recursion
8. The root node in the B-Tree technique has ___ limit on the number of children?
a. Lower
b. Upper and Lower
c. Upper
d. No
9. The best possible value of the problem objective, written as a function of the state, is called the ___.
a. Value function
b. Control variables
c. Policy function
d. Principle of Optimality
10. We use ___ for finding solutions to sub-problems, so as to reduce recalculation.
a. Backtracking
b. Recursion
c. Memoization
d. Branch and bound algorithms
11. With respect to finding the time complexity of Kruskal’s algorithm, which operation keeps track of the
parent pointer until it reaches the root parent?
a. Makeset
b. Union
c. Find
d. Merge
12. ___ means calculating the minimum amount of work required to solve the problem.
a. Upper-bound
b. Lower–bound
c. Adversary
d. Problem reduction
13. In a decision tree, a node represents a ___.
a. Input value
b. Output value
c. Solution
d. Decision
14. Which one of the following statements is true?
a. An algorithm should have one or more inputs externally and it should produce one or more output.
b. An algorithm may or may not terminate after a finite number of steps.
c. To analyze an algorithm means to determine the number of resources necessary to execute it.
d. Procedure, function and subroutine are synonyms for an algorithm.
15. In distribution counting, one array is used to store ___ value and another to store ___ list of elements.
a. Frequency, Sorted
b. Distribution, Sorted
c. Frequency, Unsorted
d. Sorted, Unsorted
16. ___ is a concept wherein larger solutions for problems are found based upon the solution of a number of
smaller problems.
a. Decrease and conquer
b. Divide and conquer
c. Branch and bound
d. Backtracking
17. Which method of encoding does not consider the probability of occurrence of symbols?
a. Static Huffman coding
b. Variable length coding
c. Adaptive Huffman coding
d. Fixed length coding
18. The ___ is also known as an escape clause which is used to terminate the algorithm.
a. Recursive step
b. Recursive function
c. Iterative step
d. Base case
19. ___ is the maximum amount of time an algorithm takes to execute a specific set of inputs.
a. Running time
b. Average case time complexity
c. Worst case time complexity
d. Best case time complexity
20. ___ of an algorithm is the amount of time required for it to execute.
a. Time complexity
b. Space complexity
c. Compiling time
d. Best case
5 marks question
1. Is the running time of merge sort depends on the value of the keys in the input file?
Explain your answer.
2. “If a DFS contains forward edge, cross edge and tree edge then it is known as DAG ”-is it
true? Justify your answer.
3. Proof that if a graph contains odd closed walk then bipartite graph is not
possible.
4. “If a graph contains a back edge then topological sort is possible”-justify the
answer.
5. There are n unsorted arrays: A1, A2, ..., An. Assume that n is odd. Each of A 1,
A2, ..., An contains n distinct elements. There are no common elements between
any two arrays. Then what is the worst-case time complexity of computing the
median of the medians of A1, A2, ..., An ?
6. What is the time, space complexity of following code:
int a=0,b=0;
for (i=0;i<n;i++)
{
a=a+rand();
}
for (i=0;i<m;i++)
{
b=b+rand();
}

7. What is the time, space complexity of following code:


int a = 0;
for (i = 0; i < N; i++) {
for (j = N; j > i; j--) {
a = a + i + j;
}
}
8. What is the time complexity of following code:
func(n)
{
if(n<=2)
return 1;
else
return(func(floor(sqrt(n)))+n);
}
9. Describe parenthesis theorem.
10.Describe white path theorem.
11.Between bubble sort and insertion sort which one is better and why?
12.Among bubble sort, insertion sort, merge sort and quick sort which one is the
best and why?
13. What is the time complexity of fun()?
int fun(int n)
{
int count = 0;
for (int i = 0; i < n; i++)
for (int j = i; j > 0; j--)
count = count + 1;
return count;
}
14.Write the Kruskal’s algorithm for minimum spanning tree.
15.Write the Prims’s algorithm for minimum spanning tree.
16.In the given graph, find the minimum spanning tree using prims algorithm.

17. In the given graph, find the minimum spanning tree using kruskal algorithm.

18. Define max flow min cut theorem.


19. Between ford fulkersion algorithm which one is better for maximum flow
algorithm.
20. Can we use Dijkstra’s algorithm to solve a maximum flow problem?give
reason.
21. Define cooks theorem.“Any NPC class problem is solvable in polynomial time then
P=NP”- justify your answer.
22.“Any NP problem is verifiable in polynomial time”- justify your answer.
23. Define a Heuristic. When a decision problem is said to be polynomial reducible?
24. Explain class NP problems. Explain NP-complete problems.
25. Explain the halting problem. Explain undecidable problems.
26. Explain the theory of computational complexity.
27. Explain class P problems. Explain the theory of computational complexity.
28. Define tractable and intractable problems.
29. Distinguish between P class and NP class.

30. What do you mean by dynamic programming? Describe asymptotic notation.


31. Define Merge sort with example.
32. Describe Quick Sort with suitable example.
33. Explain the applications of depth first search algorithm.
34. State the Greedy Knapsack Problem.
35. Explain Recursive Binary search algorithm with suitable examples.
36. Explain the greedy technique for solving the Job Sequencing problem.
37. Determine Sum of subsets problem.
38. What are the Techniques about Graphs explain it?
39. Explain DFS with suitable example?
40. Explain Reduction Source Problems.

15marks questions

1. Write an algorithm of Merge sort and find out its average time complexity.

2. In a dance competition, 7 group{A,B,C,D,E,F,G} is selected for the final round. Each


group get {40,30,42,30,45,40,41} points. Now arrange the group in such a manner that lowest
group can perform their dance at first of the final round. Solve the above situation using
divide and conquer paradigm where the required running time must be minimum.
3.Write down the algorithm of Quicksort and analysis its worst and average time
complexity.
4.Modify the BFS algorithm in such a way so that it can find shortest path of any
graph.Also find its complexity.
5. Explain dfs algorithm with example.
6. Prove that in a depth-first search of an undirected graph G, every edge of G is either a tree
edge or a back edge.
7. Show that edge (u,v) is {d(u) is discovery time of node u and f(u) finishing time
of node u} a) a tree edge or forward edge if and only if d(u) < d(v) < f(v) < f(u) , b)
a back edge if and only if d(v)<= d(u) < f(u) <=f(v) , and c) a cross edge if and
only if d(v) < f(v) < d(u) < f(u) .
8.Prove that T OPOLOGICAL -S ORT produces a topological sort of the directed
acyclic graph provided as its input.
9. Find out the complexity of strongly connected components.
10.Examine the Algorithm1 below and answer the following questions.
a) What is the function of the procedure Agorithm1?
b) What is the time complexity of the procedure?
c) If A[l .. r] = [24, 30, 09, 46, 15, 19, 29, 86,78], what is the output?
Algorithm1(A,l,r) //Input : Array A(l .. r)
{
x ← A[l]; i ← l; j ←r;
while i < j do
{
while A[i] ≤ x and i ≤ r do
i ← i +1;
while A[j] > x and j ≥ l do
j ← j -1;
if i< j then
exchange A[i] ↔ A[j];
q ← j;
}
exchange A[l] ↔ A[q];
}
11. Examine the Algorithm2 below and answer the following questions.
Find out the value of i, j, k.
What is the time complexity of the procedure?
If we replace the line p++ with the line p=p+2 then what will be the value of i, j, k. Is there
any change in time complexity then explain it.
Algorithm2()
i=0,j=0,k=0;
p=start;
while(p<=end)
{
k=k*p;
if(odd(p))
i=i*p;
else
j=j*p;
p++
}

31.12. What willbe the running time of Quicksort in the following situation?
i. Elements of array A have same value.
ii. Elements of array A are already sorted.
iii. Each time the pivot element is placed at the middle of the array or sub-array.
iv. The array is partitioned in 9:1 ratio
12. What is the running time of BFS if we represent its input graph by an adjacency matrix
and modify the algorithm to handle this form of input?
13.Breadth First Search (BFS) is started on a binary tree beginning from the root vertex.
There is a vertex t at a distance four from the root. If t is the n-th vertex in this BFS traversal,
then what will be the maximum possible value of n?
14.Prove that A directed graph G is acyclic if and only if a depth-first search of G yields no
back edges.
15. Give an algorithm that determines whether or not a given undirected graph G=(V, E)
contains a cycle. Your algorithm should run in O(V) time, independent of |E|
16. Explain topological sort with algorithm and example.
17. Explain strongly connected components with algorithm and example.
18. Describe dijkstra algorithm and explain the complexity.
19. In the given graph, find the shortest path from v1 to v8 and v7 using dijkstra algorithm.

20. Find the maximum flow from the following graph between s and t.
21. Prove that 3 coloring problem is a NPC problem.
22. Define vertex cover problem. Write a nondeterministic algorithm of VCP.
23. Define clique decision problem. Write a nondeterministic algorithm of CDP.
24. Define independent set problem. Write a nondeterministic algorithm of ISP.
25. Prove that 3SAT is NPC. Prove that VCP is NPC.
26. Prove that ISP is NPC. Prove that CDP is NPC.
27. If P!=NP then prove that NPC ⋂ P=ф
29. A)“ The problem of determining whether there exists a cycle in an undirected graph is
in NP.”-justify the statement.
B)Let S be an NP-complete problem and Q and R be two other problems not known to be
in NP. Q is polynomial time reducible to S and S is polynomial-time reducible to R.then
what will be Q and R?
C) Consider two decision problems Q1,Q2 such that Q2 reduces in polynomial time to 3-
SAT and 3-SAT reduces in polynomial time to Q1.Then what will be the class of Q1 and
Q2

30. Briefly explain the classes NP hard and NP complete.


31. State 0/1 knapsack problem and design an algorithm of LC Branch and Bound and find
the solution for the knapsack instance with any example?
32. Explain any one application of branch and bound.
33. Apply the branch-and- bound technique in solving the travelling salesman problem .
34. Briefly explain the FIFO brach and bound solution with example.
35. What are the Techniques about Graphs explain it? Explain Hamiltonian cycles with
examples.
36. Explain the Single source shortest path problem with an example. State the principle of
optimality. Find two problems for which the principle does not hold.
37. Explain how Matrix – chain Multiplication problem can be solved using dynamic
programming with suitable example.
38. Discuss the General plan for analyzing efficiency of Non recursive & Recursive
algorithms Understand
and Selection Sort with example?
39. Explain how many algorithms can you write for solving find the prime numbers.
Compare which is the simplest and the most efficient. Differentiate between Best, average
and worst case efficiency.
40. What are the different mathematical notations used for algorithm analysis. Give the
algorithm for matrix multiplication and find the time complexity of the algorithm using
step count method.

You might also like