Recent questions tagged algorithms

2 2 votes
1 1 answer
124
124 views
For $T(n,n)$, consider:$T(x,c) = \Theta(x)$ for $c \leq 2$$T(x,y) = \Theta(x) + S(x,y/2)$$S(c,y) = \Theta(y)$ for $c \leq 2$$S(x,y) = \Theta(y) + T(x/2,y)$What is the asy...
2 2 votes
1 1 answer
111
111 views
For $T(n,n)$, consider:$T(x,c) = \Theta(x)$ for $c \leq 2$$T(c,y) = \Theta(y)$ for $c \leq 2$$T(x,y) = \Theta(x) + T(x,y/2)$ What is the asymptotic complexity of $T(n,n)$...
2 2 votes
1 1 answer
126
126 views
For $T(n,n)$, consider:$T(x,c) = \Theta(x)$ for $c \leq 2$$T(c,y) = \Theta(y)$ for $c \leq 2$$T(x,y) = \Theta(x+y) + T(x/2,y/2)$What is the asymptotic complexity of $T(n,...
4 4 votes
1 1 answer
129
129 views
Consider the following recursive C function:int fun(int n) { if (n <= 1) { return n; } else { return fun(n - 1) + fun(n - 2); } }What is the time complexity of $\texttt{f...
1 1 vote
1 1 answer
136
136 views
Consider the following C code:int total = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { total += i * j * k; } } }What is th...
2 2 votes
1 1 answer
114
114 views
Suppose $f(n) \in \Omega(n^2)$.Classify the following statements:$\text{S1}$. $f(n) \in \Omega(n^3)$ $\text{S2}$. $f(n) \in \Omega(n)$ $\text{S3}$. $f(n) \in O(n)$ $\text...
3 3 votes
1 1 answer
122
122 views
Arrange the following functions in increasing order of asymptotic growth:$f_1(n) = n^{\sqrt n}$$f_2(n) = 2^n$$f_3(n) = n^{10}\cdot 2^{n/2}$$f_4(n) = \sum_{i=1}^{n}(i+1)$ ...
2 2 votes
1 1 answer
110
110 views
Arrange the following functions in increasing order of asymptotic growth:$f_1(n) = 2^{2^{1000000}}$$f_2(n) = 2^{100000n}$$f_3(n) = {}^{n}C_{2}$$f_4(n) = n\sqrt n$ $f_1(n)...
3 3 votes
1 1 answer
131
131 views
Consider the following C code:int sum = 0; for (int i = 0; i < n; i++) { sum += i; int k = n; while (k 0) { k = k / 2; } }What is the time complexity?$O(n)$ $O(\log n)$ ...
4 4 votes
1 1 answer
142
142 views
Arrange the following functions in increasing order of asymptotic growth:$f_1(n) = \log(n^n)$$f_2(n) = (\log n)^n$$f_3(n) = \log(n^{6006})$$f_4(n) = (\log n)^{6006}$$f_5(...
4 4 votes
1 1 answer
125
125 views
Suppose we have three functions $f(n)$, $g(n)$, and $h(n)$ such that:$f(n) \in O(g(n))\qquad$ and $\qquad g(n) \in O(h(n))$Which of the following statements are guarantee...
3 3 votes
1 1 answer
122
122 views
Suppose $g(n) \in \Theta(n^3)$.Which of the following statements are always true?$\text{S1}:$ $g(n) \in O(n^3)$ $\text{S2}:$ $g(n) \in \Theta(n)$ $\text{S3}:$ $g(n) \in \...
4 4 votes
1 1 answer
131
131 views
Arrange the following functions in increasing order of asymptotic growth:$f_1(n) = n^{0.999999}\log n$ $f_2(n) = 10000000n$ $f_3(n) = 1.000001^n$ $f_4(n) = n^2$ $f_1(n)< ...
0 0 votes
0 0 answers
3
3 views
GATE CSE 2014 | Set 2 | Question: 23The number of distinct minimum spanning trees for the weighted graph shown below is ________.
5 5 votes
2 2 answers
598
598 views
Which of the following statements is/are correct?A.Merge sort always has more number of swaps that comparisonsNumber of comparisons in partition algorithm are same for be...
0 0 votes
0 0 answers
6
6 views
In how many ways can we insert the elements 1,2,3,4,5,6,7into an empty AVL tree so that no rotations are needed?
0 0 votes
1 1 answer
73
73 views
What is the worst-case time complexity of inserting $n^{2}$ elements into an AVL Tree that already contains $n$ elements?
0 0 votes
2 2 answers
85
85 views
Which algorithm detects cycles in an undirected graphTopological Sort Prims Union Find Dijkstras
1 1 vote
1 1 answer
52
52 views
Stooge Sort is a highly inefficient recursive sorting algorithm that works by repeatedly sorting overlapping portions of the array.The algorithm operates as follows:Compa...
0 0 votes
1 1 answer
58
58 views
Given a permutation $a_1, a_2, \ldots, a_n$, where an inversion is defined as a pair $(i, j)$ such that $i < j$ and $a_i a_j$.If the array has at most $n$ inversions, wh...
0 0 votes
1 1 answer
52
52 views
Given two algorithms to build a Max Heap from an array of n elements: Program $1$ (Bottom-Up): Apply Heapify at each index starting from $\mathrm{n} / 2$ down to $1$Progr...
0 0 votes
1 1 answer
55
55 views
Time Complexity for finding number of connected components
0 0 votes
1 1 answer
45
45 views
Time complexity of creating a sorted linked list with n elements. Initially the list is empty.
0 0 votes
1 1 answer
172
172 views
1. what is the space Complexity of efficient Quick sort algorithem for best case ? in a lecture Reddy Sir Said that it is O(1) is this correct  2.if in the gate exam if t...
0 0 votes
0 0 answers
3
3 views
1.what is the space Complexity of efficient Quick sort algorithem for best case ? in a lecture Reddy Sir Said that it is O(1) is this correct.2. if in the gate exam if th...
1 1 vote
1 1 answer
123
123 views
How many number of comparison are required in worst case to find out second smallest element of $n$ elements list?$n+\lceil\log n\rceil-1$$n+\lceil\log n\rceil$$\lceil\lo...
0 0 votes
0 0 answers
111
111 views
Arrange the following algorithms from the most efficient to least efficient based on their time complexity.Kruskal's AlgorithmBreadth first search AlgorithmBellman-Ford A...
0 0 votes
1 1 answer
128
128 views
Given below are two statements: one is labelled as Assertion A and the other is labelled as Reason RAssertion A: Kruskal's algorithm and Prim's algorithm always produce m...