0% found this document useful (0 votes)
73 views12 pages

Sem4 Daa - 2

The document is a past exam paper for a Design and Analysis of Algorithms course. It contains multiple choice and long answer questions testing knowledge of algorithm analysis concepts like time complexity, asymptotic notation, sorting algorithms and graph algorithms. Some key points: - Part A contains 20 multiple choice questions testing topics like complexity classes, recurrences, sorting algorithms and graph algorithms. - Part B contains 5 long answer questions asking students to write algorithms, solve recurrences, perform matrix multiplication using Strassen's method, and explain problems like the 4 queens problem. - Part C contains 1 long answer question asking students to explain algorithm design paradigms like greedy, divide and conquer, dynamic programming, backtracking.
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)
73 views12 pages

Sem4 Daa - 2

The document is a past exam paper for a Design and Analysis of Algorithms course. It contains multiple choice and long answer questions testing knowledge of algorithm analysis concepts like time complexity, asymptotic notation, sorting algorithms and graph algorithms. Some key points: - Part A contains 20 multiple choice questions testing topics like complexity classes, recurrences, sorting algorithms and graph algorithms. - Part B contains 5 long answer questions asking students to write algorithms, solve recurrences, perform matrix multiplication using Strassen's method, and explain problems like the 4 queens problem. - Part C contains 1 long answer question asking students to explain algorithm design paradigms like greedy, divide and conquer, dynamic programming, backtracking.
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/ 12

Reg. No.

B.Tech. DEGREE EXAMINATION, MAY 2018


Third Semester

IT1004 DESIGN AND ANALYSIS OF ALGORITHMS


(For the candidates admitted during the academicyear 2013-2014 and 2014 - 2015)

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

PART A (20 x 1 = 20 Marks)

Answer ALL Questions

1. What is the time complexity of fun ( )?


int fun (int n)
int count =0;
for (int i= n; i>0,iF2)
forG-0;j<i,j++)
count+=1|
return count;

(A) O ( (B) O (nlog n)


(C) O(n) (D) O(nlog log n)
2. The recurrence relation capturing the optimal time of the tower of Hanoi problem with n disc is
(A) T(n) = 2T(n-2)+2 (B) T(n) =27(n-1) +n
(C) T(n)=2T(n/2)+1 D) T(n) =2T(n-1)+1
3. Let w(n) and A(n) denote respectively, the worst case and average case running time of an
algorithm executed on an input size n. Which of the following is always true?

(A) A(n) = 2(»w(n) (B) A(n) =0(w{n)


(D) An) = o(w(n)
(C)A(n) =0(w{n))
4. Which of the given options provide the increasing order of asymptotic complexity of functionfi,

o fs and fi? hn)=2": fn)=r fn) nlogn; f*() =, logn


=

(A) 32.f4: (B) S2.h.s4


(C)S2»/3»JvJ4 D) 2/3fash
5. What is the worst case time complexity of insertion sort where position of the data to be inserted is
calculated using binary search?
(A) n (B) n logn
(C) n? (D) (n log n)
6. What does it mean when we say that an algorithm X is asymptotically more efficient than Y?
(A) X will be better choice for all inputs (B) X will be better choice for all inputs except
small inputs
(C) X will be better choice for all inputs (D) Y will be better choice for small inputs
except large inputs
28MA3IT1004
Page 1 of 4
required to find the minimum and the maximi
7. What is the minimum number of comparisons
100 numbers
(B) 147
(A) 148
D) 140
(C) 146
worst-case complexity?
8. Which of the following sorting algorithm has the lowest
(B) Bubble sort
(A) Merge sort
(D) Selection sort
(C) Quick sort
element is selected as point using as Ofn
9. In for sorting n elements, the (n/4)th smallest
quick sort, of quick sort?
time algorithm. What is the work case time complexity
(A) e (n) (B) 0 (n log n)
(C) 0 (n) (D) 0 ( log n)
used in finding all pairs of shortest distance
10. Which of the following algorithm design technique is
in a graph?
(B) Back tracking
(A) Dynamic programming Divide and conquer
(C) Greedy (D)
of followed immediately by a
. An array of size n, comprised of an increasing sequence numbers to determine if a given
decreasing one. What is worst case time complexity of optimal algorithm
number X' is in the array?
(A) 0 (n) (B) e (log n)
(C) 0 (n) (D) 0 (n log n)
12. The main measure for efficiency of algorithm are
(A) Processor and memory (B) Complexity and capacity
(C) Data and space D) Time and space

13. What does the algorithmic analysis count?


(A) The number of arithmetic and the (B) The number of lines of code in a program

operation that are required to run the


program
(C) The number of seconds taken by (D) Total number of variables used in the program
program to execute
14. Express the formula (n-1) * (n-5) in terms of big-oh notation
(A) O (1) (B) O (log n)
(C) On) (D) O (n)

15. The time complexity of binary search is


(A) O (n) (B) O (log n)
(C) O (n) D) O (n log n)

16. What is the time complexity of Floyd-Warshall algorithm to calculate all pair shortest path in a

graph with 'n' vertices?


(A) O n log n) (B) 0 (n log n)
C) 0 (n) (D) e n)
17. Which of the following sorting procedures is the slowest?
(A) Quick sort (B Bubble sort
(C) Heap sort (D) Merge sort
18. A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort
algorithm. What is the worst case running time?
(A) O (n log n) (B) O (n?
C) O (n) (D) O (n!)

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.

22. Solve the relation x(n) = x(n-1) + n;n > 0;x(0) = 0.

23. Using Strassen's method, computer A xB


4 81p_5 12
A-2 16 B15 20
24. Write a recursive algorithm to compute factorial write its time complexity.

2. Solve T(n) = 47(n/2) +n using masters theorem.

26. Find the shortest path for the given graph using Marshall algorithm.
10
s
12
13
8

27. Explain the 4' queen's problem with an illustration.


PART C (5x 12 =60 Marks)
Answer ALL Questions

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.

B. Tech. DEGREE EXAMINATION, DECEMBER 2016


Third Semester

IT1004 DESIGN AND ANALYSIS OF ALGORITHMS


(For the camdidates admitted from the academic year 2013-2014 and 2014-2015)
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.
(i) Part-B and Part-C should be answered in answer
booklet.
Time: Three Hours Max. Marks: 100

PART-A (20 x 1 = 20 Marks)

Answer ALL Questions


1. Two main measures for the efficiency of an algorithm are
(A) Processor and memory (B) Complexity and capacity
(C) Time and Space (D) Data and Space

Which of the following does not exist in the complexity theory


(A) Best case (B) Worst case
(C) Average case D) Null case

3. The worst case occur in linear search algorithm when


(A) Item is somewhere in the middle of the array.
(B) Item is not in the array at all
(C) Item is the last element in the array
D) Item is the last element in the array or is not there at all

The complexity of the binary search algorithm is


(A) On) (B) Ologn)
C) O) (D) O(nlogm)
The operation of processing each element in the list is known as
(A) Sorting (B) Merging
(C) Inserting (D) Traversal

6. What does the algorithmic analysis count?


(A) The number of arithmetic and the operations that are required to run the program
(B) The number of lines required by the program
(C) The number of seconds required by the program to execute
D) Memory allocation for the program

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

in insertion sort to sort a file if the file is sorted in


9. How many comparisons are required
reverse order?
(B) N
(A) N?
(C) N-1 (D) N/2

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

13. The total running time of Huffman on the set of n characters is


(A) O (n) (B) On log n)
(C)O(n) D) O(log n)

14. 8 Queen's problem is coming under the concept of


(A) Back tracking B) Greedy
(C) Dynamic (D) Divide and conquer

15. The BST search uses which approach to algorithm design?


(A) Divide and conquer (B) Greedy
(C) Brute force (D) Dynamic programming

16. Which indicates pre-order traversal?


(A) Left, Right, Root (B) Right, Left, Root
(C) Root, Left, Right D) Right, Root, Left

17. technique is for solving problems with overlapping sub problems.


(A) Divide and conquer (B) Greedy techniques
(C) Back tracking D) Dynamic programming

18 Distance matrix can be generated using the following algorithm


(A) Dijkstra (B) Prim's
(C) Kruskal D) Floyd
19. Which of the following is not a greedy method
(A) Prim's (B) Kruskal
C) Dijkstra D) Warshal

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)
=

Answer ANY FIVE Questions

21 Sort a list ofemployee records in ascending order using emp id.


which takes
Propose an algorithm
running time no worse than n log n.
22. State the Euclid algorithm for
computing GCD of two numbers.
23 Solve the recurrence equation T(n) = T(n-1)tn, for n> 1 using substitution method of
mathematical analysis.

24. Draw the graph of different order of growth functions.


25. Explain the pseudo code to find the height of the Binary tree.

26. Justify Hamiltonian cycle problem is NP hard.

27. Compare greedy algorithm and dynamic programming.

PART-C (5x 12= 60 Marks)


Answer ALL Questions

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.

30.a. Apply quick sort for the following:


(10, 12, 5, 9, 4, 11, 8, 3, 13). Write the pseudo code and derive its complexity.

(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

32.a.i. Explain 8-Queen problem with respect to backtracking concept. (8 Marks)

ii. Write short notes on sum of subset problems. (4 Marks)

(OR)
b. Explain Travelling Salesman problem with suitable example.

*** **|

Page 4 of 4
02DA3IT1004
Reg. No.

B.Tech. DEGREE EXAMINATION, MAY 2018


1st to 6th Semester

15CS204J -

ALGORITHM DESIGN AND ANALYSIS


(For the candidates admitted during the academic year 2015 -2016 onwards)
Note:
and OMR sheet should be handed
) Part A should be answered in OMR sheet within first 45 minutes
over to hall invigilator at the end of 45th minute.
Part B and Part - C should be answered in answer booklet.
i)
Max. Marks: 100
Time: Three Hours

PART A (20 x 1 =20 Marks)


Answer ALL Questions

1. What does the algorithmic analysis count?


that are required to run the program
(A) The number of arithmetic operations
(B) The number of lines required by the program
(C) The number of seconds required by the program
(D) The number of conditions required by the program
2. Let T(n) =(3n+2n +2)logn. What is the time complexity?
(A) O (n) (B) O (n +)
C) O (r log n) D) O n log n)

3. Which sorting algorithm is faster?


(A) Bubble sort (B) Insertion sort
(C) Nonlinear sort D) Quick sort

4. The time factor when determining the efficiency of algorithm is measured by

(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) =

(C) Recurrence is T(n) =


2T(n/2) +O(n) and time complexity is Ofn log n)
(D) Recurrence is T(n) =
T(n-1) +O(n) and time complexity is O(r)

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

7. Worst case efficiency of binary search is


+1 (B) n
(A) Log2 n
(D) 2"
(C)

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

10. Which of the following is not a backtracking algorithm?


(A) Knight tour problem (B) N-queen problem
(C) Tower of Hanoi (D) M coloring problem

11. What is the time complexity of the Floyd Warshall algorithm to calculate all pair shortest

path in a graph with N vertices?


(A) O (* log n} (B) r log n)
(C) (n) (D) (*')
12. Which of the following algorithm design technique is used in finding all pairs of shortest
distances in a graph?
(A) Dynamic programing (B) Back tracking
(C) Greedy (D) Divide and conquer

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

14. A solution that either.maximizes or minimizes a given objective function is called an


(A) Optimal solution (B) Feasible solution
(C) Local solution D) Exact solution

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)

20. T(n) = 27(n/2) +n then T(n) =

(A) O (n°') (B) O n)


(C)On) (D) O(n°)
PART-B (5x4 20 Marks)
Answer ANY FIVE Questions

21. Prove the equations using mathematical induction, where, T(1) =


0, T(n) 2T (n/2) + n,

where n >2.

relation using forward substitution method: t, =


tn-1 +3 with initial
22. Solve the recurrence

condition to=4.

23.
Multiply the following two matrices using the Strassen method A =|. B- 1
and

find the general resultant.

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

and NP-hard with suitable example.


26. Distinguish between NP-complete
randomized algorithms.
27. List the merits and demerits of

PART-C(5x 12 =60 Marks)


Answer ALL Questions

87(n/2)+10n, T(0) =0.


0.2.1.
Solve the recurrence relation using Mastertheorem: T(n) =
=1.
11. Solve the recurrence equation 1, =ntn-1 for
n >11to

(OR)
*. Prove that t(n) ofthis algorithm is
algorithm. Let g/n)
=

DLet 1(n) =3n' +2n+3 for an

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.

construct a Minimum Spacing Tree (MST) for the following


30. a. Use Kruskal's algorithm and
graph

(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

31. ai. Explain Hamiltonian cycle.


with suitable example.
ii. Explain the algorithm for graph coloring problem
(OR)
b. How 8 queens problem could be solved using back tracking method? Explain.
bound technique
32. a. Solve the following Knapsack problem using branch-and
Items W Vi
2 8
2 3 6
32 4
6.
Knapsack capacity
=

With w

(OR)
b. Write a randomized algorithm for Hiring problem' and analyze the time complexity.

* ** **

10MF1-6/15CS204J

Page 4 of 4

You might also like