Professional Documents
Culture Documents
→ 2 n log 2 n
c.3n n
for n 4
04. Ans:(a)
Sol: I n km C.n m for n n 0 and n km C.n m 08. Ans: (d)
for n ≥ n0 Sol: (a) 2n n! n 1 but
n! ≰ C. nlogn n no (false)
n k n m
m
II 2 n 1 3.2 n for n ≥ 1 (b) 2n ≱ 2n! n 1 (false)
(c) n! ≰ C. 2n n 5 (false)
2 n 1
O2 n
(d) nlogn C. 2n n no and
III 2 ≰ C.2 for n ≥ 1
2n n
n! C. 2n for n 1 (true)
ACE Engineering Publications Hyderabad|Delhi|Bhopal|Pune|Bhubaneswar| Lucknow|Patna|Bengaluru|Chennai|Vijayawada|Vizag |Tirupati | Kukatpally| Kolkata
: 2 : Algorithms
2 n
(E – 2) an = n
Characteristic equation (E) = 0
f 2n requires n because i runs n times
E–2=0
(n)
characteristic root = 2
Complementary function = C1 2n
21. Ans: (c)
Let an = An + B
Sol: f 1 8 2 * f 1 7 3 * f 6 1640
Substitute ‘an’ in equation (1)
f 1 7 2 * f 1 6 3 * f1 5 547
An + B = 2{A(n–1) + B} + n
An = 2An + n B = –2A + 2B f 1 6 2 * f 1 5 3 * f 1 4 182
19.
Sol: T(n) = O(n2) Recursive Iteration
2 4
The shortest path from S → T is SACET.
(b) P Q R U S T -Valid
1 3 4
15.
2 7 Sol:
(c) P Q R U T S -Invalid 0.13
1 3 4
0.05 0.08 0.11 0.17 0.19 0.40
7 3 b d f c a e
(d) P Q T R U S -Invalid
1 2 4
0.24
algorithm.
5 7 11 6 9 70
25. Ans: (d)
Sol: Based on Kirchoffs Theorem
22. Ans: (d)
Sol: If x is found at loc ‘1’
26. Ans: (a)
1 comparison
Sol:
x is found at loc ‘2’ 32
2 comparisons
30 25
x is found at loc ‘3’
15 12 20 16
3 comparisons
x is found at loc ‘n’
27. Ans: (d)
‘n’ comparisons
Sol: Since the degree of u & v in ‘G’ is at least 2.
Total comparison = n(n+1)/2
n(n 1)
28. Ans: (d)
Therefore average = 2
n Sol: 1
3 5 6
23. Ans: (c)
Sol: (c) is always true but (b) & (d) are true in 8 9
only few cases. (a) is never true. Tree for option (a) ‘1’ in at top but not
65 10 20 35
3 1
Tree for option (d) is max Heap x
3 1
binary search for finding the correct position
then we need to do (loglogn) comparisons.
(a) Original tree
In reality, it is not possible to perform binary
Inserting 7
9 search on elements from leaf to root as they
7 6 8 are not in sequence.
3 1 5
31. Ans: (b)
Inserting 2
9 Sol: Procedure Heapify with adjust would
require time of O (n) for n-elements, now
7 6 8
with addition n-elements, total being ‘2n’
3 1 5 2 would still be order of O (n).
3 1 5 2 6 4
06. Ans: 34
5. Dynamic Programming
Sol:
i A
0 1 2 3 4 5
i q p q r r
01. Ans: (a)
0 0 0 0 0 0
p 0 0 1 1 1 1 p
q 0 1 1 2 2 2 q
02.
p 0 1 2 2 2 2
Sol: for i 1 to n r 0 1 2 2 3 3
q 0 1 2 3 3 3 r
for j 1 to n
r 0 1 2 3 4 4 r
if (A[i ,j ] = 0) then P [i, j] = 0; p 0 1 2 3 4 4
else P[i ,j ] =1;
for i 1 to n LCS = pqrr
Sol: As per the given recurrence, it is based on See the recurrence of Matrix Chain Product.