Answer: A Sol. Big-Oh Notation Represents The Worst Case - So Highest Magnitude Among The Function Represent
Answer: A Sol. Big-Oh Notation Represents The Worst Case - So Highest Magnitude Among The Function Represent
Answer: a
Sol. As the given array is sorted, required elements will be find in O(n) time
(a) 2 only (b) 3 only (c) 2 and 3 only (d) All of the above
Answer: c
Sol. 1. Big-Oh function is the upperbound of the fuction i.e g(n) is upper bound of f(n). So, it
doesn’t follow symmetric property.
3. As g(n) is the worst case for f(n). So, f(n) is the best case of g(n). It follows transpose
property.
Q3. There are four non-negative functions are given as f(n) =O(d(n)) and g(n)= O(e(n)). Then
which of the following expression is correct
Answer: a
Sol. Big-Oh notation represents the worst case . So highest magnitude among the function represent
the complexity
f(n)+ g(n) =max (d(n), e(n)) Highest magnitude of the two function in addition.
A B C D
(a) p r q s
(b) r s p q
(c) r s q p
(d) p s r q
Answer: c
Sol.
Kruskal is greedy about the minimum weight in each iteration and used for MST
construction.
In Quick Sort we use divide and conquer paradigm
In Hamiltonian Circuit we use backtracking
All pair shortest path use Dynamic Programming paradigm (Floyd Warshall algorithm )
1. log(log^a n)
2. log(n!)
3. log^a(n!)
4. log^a(logn)
Answer: b
Sol.
Q6. Given a set of m = 2^n distinct numbers, we would like to determine the smallest
and the second smallest using comparisons. Which of the following statements is TRUE?
Answer: d
Sol.
Q7. Consider a plate stacked with several disks, each of a different diameter (they could
all be, for instance, chapatis or parantha of different sizes). We want to sort these disks
in decreasing order according to their diameter so that the widest disk is at the bottom of
the pile. The only operation available for manipulating the disks is to pick up a stack of them
from the top of the pile and invert that stack. (This corresponds to lifting up a stack, chapatis
or parantha between two big spoons and flipping the stack.)
Answer: c
Q8. There are n lists are given with m elements each sorted in non-decreasing order. Merging
these lists into a single sorted list will take time.
Answer : b
Since, each list is sorted in ascending order use directly merge procedure of merge sort algo.
Take two list and merge..so one pair will take 2m time.
So, total pairs in first level will be n/2 . So total cost for one level is (n/2)*2m=nm.
In next level cost for one pair is 4m and no of pairs will be n/4 .. so next level cost will be nm .
n/2^k=1..
k= logn(base 2)
Q9. What will be the time complexity for the following pseudo code:
Sum = 0;
Answer: c
Sol. Sum = 0;
{ for (i=1; j<=n; j++)----------(for every value of i this will run n times )
n^2.