Recent questions tagged time-complexity

4 4 votes
1 1 answer
557
557 views
Someone help with this...I am getting option-b but key is opt-aa)b)c)d)
0 0 votes
1 1 answer
328
328 views
You were given an array of distinct elements of size n with indices starting from 0.-Every $(2i)^{th}$ element is pushed into a stack.-Every $(2i+1)^{th}$ element is enqu...
1 1 vote
2 answers 2 answers
619
619 views
O(n)∗Ω(n)+Θ(n) = ?1.O(n)2.Ω(n)3.Θ(n)4. none 
2 2 votes
1 1 answer
649
649 views
What is the complexity of the following using Big O:
1 1 vote
1 1 answer
420
420 views
Match the LIST-I with LIST-II$\begin{array}{|l|l|l|l|} \hline & \textbf{LIST-I} & & \textbf{LIST-II} \\ & \textbf{Algorithm} & & \textbf{Complexity} \\ \hline \text{A.}...
1 1 vote
1 1 answer
414
414 views
Arrange the following recurrence relations in increasing order of their time capacity.$\mathrm{T}(\mathrm{n})=\mathrm{T}(\mathrm{n} / 2)+1$$\mathrm{T}(\mathrm{n})=2 \math...
0 0 votes
1 1 answer
408
408 views
Match List - I with List - II.$\begin{array}{llll} & \textbf{List - I} & & \textbf{List-II} \\ & \textbf{(Recurrence Relations)} && \textbf{(Complexity)} \\ \text{(A)}& \...
2 2 votes
3 3 answers
406
406 views
Which of the following is $\text{TRUE}?$The cost of searching an AVL tree is $\theta(\log n)$ but that of binary search is $0(n)$The cost of searching an AVL tree in $\th...
1 1 vote
1 1 answer
419
419 views
We have an array $A$ of $n$ numbers, where $n$ is a power of $2$.We build a full binary tree on top of the array $A.$ The elements of the array are leaves of the tree, nu...
1 1 vote
1 1 answer
318
318 views
We have an array $A$ of $n$ numbers, where $n$ is a power of $2$.We build a full binary tree on top of the array $A.$ The elements of the array are leaves of the tree, nu...
3 3 votes
1 1 answer
228
228 views
Which of the following operations can be performed in $\mathrm{O}(\log n)$ time in a binary heap?Deleting the root elementInserting an elementBoth $\text{(A)}$ and $\text...
1 1 vote
0 0 answers
151
151 views
What is the time complexity for searching an element in a balanced Binary Search Tree?$\text{O}(1)$$\text{O}(\log n)$$\text{O}(n)$$\text{O}(n \log n)$ 
1 1 vote
1 1 answer
151
151 views
Which of the following is the correct asymptotic notation for an algorithm that grows slower than $\text{O}\left(n^{\wedge} 2\right)$ but faster than $\text{O}(n)?$$\text...
2 2 votes
1 1 answer
587
587 views
We have an array $A$ of $n$ numbers, where $n$ is a power of $2$.We build a full binary tree on top of the array $A.$ The elements of the array are leaves of the tree, nu...
5 5 votes
4 4 answers
497
497 views
The next two questions pertain to the following code which takes a non-negative integer as input}.function FOO(n) if (n=0) then return 0 else if (n=1) then return 1 else ...
2 2 votes
1 1 answer
503
503 views
What is the solution to the following recursion?$$\begin{array}{l}T(n)=T\left(\dfrac{n}{2}\right)+T\left(\dfrac{n}{3}\right)+T\left(\dfrac{n}{6}\right)+O(n), \\T(n)=5 \qu...
3 3 votes
2 2 answers
569
569 views
Recall the insertion sort algorithm: procedure INSERTIONSORT(A) for i ← 1 to A.length - 1 do key ← A[i] j ← i - 1 while j ≥ 0 and A[j] key do A[j + ...
2 2 votes
0 0 answers
397
397 views
There are $n$ people in a house and $n$ pairs of shoes such that the $i$-th shoe fits the $i$-th person's feet (and no one else's). A burglar comes and throws the shoes a...
1 1 vote
2 2 answers
382
382 views
Given an array $A=\left(a_{0}, a_{1}, \ldots, a_{n-1}\right)$ of integers, your task is to determine the maximum possible sum\[\operatorname{maxsum}(A)=\max _{0 \leq s \l...
2 2 votes
1 1 answer
472
472 views
Let $R$ be the root of a balanced binary search tree having $n$ nodes, where each node contains an integer, a pointer to its left child and a pointer to its right child. ...
0 0 votes
3 3 answers
395
395 views
For functions $f, g: \mathbb{N} \rightarrow \mathbb{R}$, we say that $f$ is $o(g)$ (in words, $f$ is $little-oh$ of $g$ ) if $\lim _{n \rightarrow \infty} \frac{f(n)}{g(...