| List-I | List-II |
|---|---|
| (a) Prim's algorithm | (i) $O(V^3\log V)$ |
| (b) Dijkstra's algorithm | (ii) $O(VE^2)$ |
| (c) Faster all-pairs shortest path | (iii) $O(E\log V)$ |
| (d) Edmonds-Karp algorithm | (iv) $O(V^2)$ |
Prim's algorithm has time complexity:
$O(E\log V)$
So,
$(a)\rightarrow(iii)$
Dijkstra's algorithm has time complexity:
$O(V^2)$
So,
$(b)\rightarrow(iv)$
Faster all-pairs shortest path algorithm has time complexity:
$O(V^3\log V)$
So,
$(c)\rightarrow(i)$
Edmonds-Karp algorithm has time complexity:
$O(VE^2)$
So,
$(d)\rightarrow(ii)$
Therefore, the correct matching is
$(a)-(iii);\ (b)-(iv);\ (c)-(i);\ (d)-(ii)$
Heapsort is an in-place sorting algorithm.
Insertion sort is also an in-place sorting algorithm.
But merge sort is not considered in-place because it requires extra memory for merging.
So, heapsort sorts in place like insertion sort, but unlike merge sort.
Therefore,
$(P,Q)=(Insertion\ sort,\ Merge\ sort)$
Using Master Theorem / recurrence expansion:
(A)
$T(n) = T(n/2) + 1$
Complexity → $O(\log n)$
(E)
$T(n) = T(n-1) + 1$
Complexity → $O(n)$
(D)
$T(n) = 2T(n/2) + \sqrt{n}$
$n^{\log_2 2} = n$
Since $\sqrt{n} < n$
→ $O(n)$
(B)
$T(n) = 2T(n/2) + n$
$n^{\log_2 2} = n$
→ $O(n \log n)$
(C)
$T(n) = 3T(n/3) + n$
$n^{\log_3 3} = n$
→ $O(n \log n)$
Increasing order
$O(\log n) < O(n) < O(n) < O(n\log n) < O(n\log n)$
The numbers are in the range
$0$ to $n^2-1$
Using radix sort with base $n$, each number can be represented using $2$ digits.
Radix sort takes
$O(d(n+b))$
Here,
$d=2$ and $b=n$
So,
$O(2(n+n))=O(n)$
Hence, the best running time is $O(n)$.
Which of the following is application of depth-first search?
Depth-first search is used in topological sorting of directed acyclic graphs.
DFS is also used in finding strongly connected components, such as in Kosaraju's algorithm and Tarjan's algorithm.
So, both topological sort and strongly connected components are applications of DFS.
Consider double hashing of the form
$h(k,i)=(h_1(k)+ih_2(k))\ \text{mod}\ m$
where
$h_1(k)=k\ \text{mod}\ m$
$h_2(k)=1+(k\ \text{mod}\ n)$
where $n=m-1$ and $m=701$.
For $k=123456$, what is the difference between first and second probes in terms of slots?
In double hashing, the difference between the first and second probe is decided by $h_2(k)$.
Here,
$m=701$
So,
$n=m-1=700$
Now,
$h_2(k)=1+($remainder when $123456$ is divided by $700)$
$123456=700\times 176+256$
So, remainder is $256$.
Therefore,
$h_2(k)=1+256=257$
Online Test Series, Information About Examination,
Syllabus, Notification
and More.
Online Test Series, Information About Examination,
Syllabus, Notification
and More.