Sem4 Daa - 2
Sem4 Daa - 2
Note:
) Part A should be answered in OMR sheet within first 45 minutes and OMR sheet should be
handed over to hall invigilator at the end of 45th minute.
Part-B and Part - C should be answered in answer booklet.
(ii)
Time: Three Hours Max. Marks: 100
16. What is the time complexity of Floyd-Warshall algorithm to calculate all pair shortest path in a
Page 2 of 4 28MA3IT1004
19. What is the run time for traversing all nodes in a binary search tree representing a disconnected
graph?
(A) O (n log n) (B) O (n)
(C) O (log n) (D) O n)
20. Huffman codes are the application of with minimal weighted external path length obtained
by an optimal set
(A) BST (B) MST
(C) Binary tree (D) Weighted graph
PART-B (5x4=20 Marks)
Answer ANY FIVE Questions
21. Write an algorithm to find maximum value in the given input series 5, 15, 3, 71, 19, 2. Anlayse
the performance.
26. Find the shortest path for the given graph using Marshall algorithm.
10
s
12
13
8
them.
28. a. Explain all paradigms of algorithm and explain each one of
(OR)
b. Write an algorithm to find second maximum and minimum value for any given input series.
Also explain its best, average and worst case time complexity.
29. a. WVrite he recursive and non-recursive version of Fibonacci series generation function. Explain
the time complexity for each.
(OR)
b. Give an recursive equation T(n) = 3T(n/3) +n, given n>1,T(1) =1. Calculate its time
complexity.
Page 3 of 4 28MA3IT1004
identify the closet pair of points in space. Explain the method
30. a. Using divide and conquer strategy,
of solution.
(OR)
the
perform all types of traversal on same
b. Construct a binary search tree and
41,92,76, 82, 30, 15, 17, 6, 22, 101.
for capacity, w=
given Knapsack problem using dynamic programming techniques
a
31. a. Solve the
10.
Item Weight Value
12 $80
$40
$20
43 $27
(OR)
b. Using Hoyd's algorithm, compute all-pair shortest path for the given graph.
6
)
32. a. Solve the given graph to find the shortest path to support salesman to travel across all cities
represented as vertices.
(OR)
b. Find the subsets for the following set of integers. {15 100 125 500 400}. Given W 75;
draw the complete state space tree.
*** **
Page 4 of 4
28MA3IT1004
Reg. No.
1. There are four algorithms A1, A2 As, As to solve the given problem with the order log(n), n
log n, log (log(n)), n /Mog n, which is the best algorithm?
(A) Ai (B) A2
(C) As (D) A4
Page 1 of 4 02DA3IT1004
8. How many passes are required to sort a file of sizen by bubble sort method?
(B) N
(A) N?
(D) N/2
(C) N-1
The correct order of the efficiency of the following sorting algorithms according to their
10.
overall running time comparison is
(B) Insertion> Bubble > Selection
(A) Insertion> Selection> Bubble
Selection> Bubble > Insertion (D) Bubble > Selection> Insertion
(C)
What is the Asymptotic runtime for traversing all nodes in a binary search tree with n
11.
nodes and printing them in order?
(A) O (n log (n)) (B) O n)
C) O(log n) (D) O(n
There are 5 items as follows (wi, vi) = (5, 30) (10, 20) (20, 100) (30, 90) (40, 160), The
12
knapsack can hold 60 pounds, find the optimal solution.
(A) 250 $ (B) 260 $
(C) 270 S (D) 290 S
Page 2 of 4 02DA3IT1004
20. Principles of optimality is used in
(A) Greedy approach (B) Dynamic approach
(C) Divide and conquer (D) Back tracking
PART B (5 x 4 20 Marks)
=
28.a. Write an algorithm to implement linear search, for the following numbers and analyze the
time complexity of the algorithm (Best and worst case) 10, 65, 78, 89, 01, 12, 03, 56, 90.
(OR)
b. Write the pseudo code of insertion sort and prove the worst case of insertion sort is O(n).
29.a. Solve the following recurrence relation using Master's theorem.
) T(n) =4 T(n/2) +O(n)
T(n) = 4 T (n/3) + O(n')
(i)
(OR)
b. Explain Asymptotic notations with detailed graph.
(OR)
b. Apply Strassen's algorithm to compute A * B. A=|
31.a. Considerthe following set of frequencies A 2, B =5, C=7, D =8, E 7, F 22, G =4, = =
H=17. Find the Huffman code using fîxed length and variable length coding for the same.
(OR)
Page 3 of 4
02DA3IT1004
b. Find the all pairs shortest path for the given matrix using Floyd-warshall algorithm
A BC D E
A(0 6-3 co
B5 0 0
Do 3 10
Elo 4 2 0
(OR)
b. Explain Travelling Salesman problem with suitable example.
*** **|
Page 4 of 4
02DA3IT1004
Reg. No.
15CS204J -
(A) Counting micro seconds (B) Counting the number of key operations
(D) Counting the kilobytes of algorithm
(C) Counting the number of statements
5. What is the recurrence for worst case of quick sort and what is the time complexity in worst
case?
(A) Recurrence is T(n) =
T(n-2) +O(n) andtime complexity is Ofn)
T(n/10) + T(an/10) +On) and time complexity Ofn log n)
is
(B) Recurrence is T(n) =
6. How do you call the selected keys in the quick sort method?
(A) Outer key (B) Inner key
C) Partition key (D) Pivot key
10MF1-6/15CS204J
Page 1 of 4
of Kruskals algorithm in finding spanning tra
minimum spanning
the minimum tree of
an
8. Time complexity n edges, if the edges are in sorted order
m vertices and
undirected graph containing (B) 0 (m+n)
(A) O (mn) (D) O (n)
(C) O (m)
all the permutations of compute the tour
9. In TSP, get all the tours by generating
we can
them
lengths and find the shortest among n-1 intermediate cities
(A) n+1 immediate cities (B)
(D) n-2 intermediate cities
(C) n+2 immediate cities
11. What is the time complexity of the Floyd Warshall algorithm to calculate all pair shortest
13. In which ofthe following cases N queens problem does not exist.
(A) n= 2 and n= 4 B) n= 4 and n =6
(C)n=2 and n=3 (D) n=4 and n=8B
15. What is an optimal Huffman code for alpha beta of the following set of frequencies a:05,
b:48, c:07, d:17, e:10, f:13?
(A) 1010 (B) 0101
(C) 1001 (D) 1100
16. Which of the following is not used to solve a 0-1 knapsack problem?
(A) Greedy (B) Dynamic programming
C) Branch and bound (D) Divide and conquer
17. Which of the following does not exist in complexity theory?
(A) Best case (B) Worst case
(C) Average case (D) Null case
18. Assuming P!= NP, which of the following is true?
(A) NP hard = NP
(B) NP complete = P
C) NP= ¢
(D) NP complete up =¢
Page 2 of 4
10MF1-6/15CS204J
I n analysis of algorithm, approximate relationship between the size of the job and the amount
to do is expressed by using
of work required
(A) Central tendency (B) Differential equation
Order of execution (D) Order of magnitude
(C)
where n >2.
condition to=4.
23.
Multiply the following two matrices using the Strassen method A =|. B- 1
and
7,instance =
m =
15
optimal solution to the Knapsack
n
24. Find an
and (w), w2.... W)
=
(2, 3, 5, 7, 1, 4, 1).
(p1. p2..p7)= (10, 5, 15, 7, 6, 18, 3)
given set ofintegers: [5 10 25 50 100] for w = 75.
25. Find the sum of subsets for the
(OR)
*. Prove that t(n) ofthis algorithm is
algorithm. Let g/n)
=
Or).
operation count for Fibonacci series and
1. Calculate the computing time
of the step count and
Big-Oh notation.
analyze the time complexity using
the
a sorted listed of elements. Analyze
4.a. Write an algorithm to perform merge sort on
case and worst case.
algorithm for best case, average
(OR)
10MF1-6/15CS204J
Page 3 of 4
the divide and conquer
b. Find the maximum and minimum
in a set of 'n' elements. Using
elements compared and solve
relation for the number of
approach. Also find the recurrence
the same.
(OR)
b. Compute Huffman coding for the set of symbols shown
below:
Symbol A BC D #
Probability 0.3 0.3 0.2 0.1 0.1
With w
(OR)
b. Write a randomized algorithm for Hiring problem' and analyze the time complexity.
* ** **
10MF1-6/15CS204J
Page 4 of 4