Recent questions tagged time-complexity

2 2 votes
1 1 answer
780
780 views
int main(){ int c = 0; for(int i = 1; i < n : i++){ for(int j = i + 1; j <= n; j++){ for(int k = 1; k <= j; k++){ c = c + 1; } } } return 0; }What will be the itme comple...
1 1 vote
1 1 answer
554
554 views
Suppose the running time complexity of EXTRACT-MAX when applied on d-ary heap of height n is Then, the value of x + y + z is ________.Note: d-ary heap can have maximum d...
0 0 votes
0 0 answers
312
312 views
Please give me suggestion I am Good at conceptual in algorithms but i am issue facing at Find time complexity of any problem.What Can i do resolve this problem .I revised...
0 0 votes
0 0 answers
146
146 views
Consider the pseudocode below, where $\mathrm{n} \% 6$ denotes the remainder when n is divided by 6 . The notation $n / / 2$ stands for integer division, i.e., $15 / / 2=...
1 1 vote
1 1 answer
247
247 views
An algorithm takes as input an nxn Boolean matrix A . If the running time of the algortihm is T(n) = O(nlogn) when n is used as the input size parameter , then which of t...
0 0 votes
1 1 answer
294
294 views
int fun(int n) { int i, j; for(i=1; i<=n; i++) { for (j=1; j<n; j+=i) { printf("%d %d", i, j); } }}Function_1 while ...
0 0 votes
1 1 answer
227
227 views
Determine the time complexity of the following loop : for ( int i = 1 ; i <= n ; i++ ) { for ( int j = 1 ; j <= i ; j *= 2) { printf ("Hi") ; } }A. O(n...
1 1 vote
0 0 answers
225
225 views
A binary search tree is a binary tree whose proper subtrees are binary search trees, and whose root is strictly greater than all elements in the left subtree, and strictl...
0 0 votes
1 1 answer
473
473 views
What is the Time Complexity of the Dijkstra when it is using Adjacency list + Array (sorted or unsorted ) ? If it is O( V^2 + E ) then ,According to the General form of A...
0 0 votes
0 0 answers
278
278 views
The input to the problem consists of (i) an array $A[1,2, \ldots, n]$ of $n$ positive integers and (ii) a positive integer $T$. We are given the guarantee that at least o...
0 0 votes
0 0 answers
129
129 views
Let $A[0 \ldots n-1]$ and $B[0 \ldots n-1]$ be two arrays containing $n$ real numbers such that $A[k] \leq A[k+1]$ and $B[k] \leq B[k+1]$ for all $k \in\{0,1, \ldots, n-2...
0 0 votes
1 1 answer
227
227 views
Let $A[0 \ldots n-1]$ and $B[0 \ldots n-1]$ be two arrays containing $n$ real numbers such that $A[k] \leq A[k+1]$ and $B[k] \leq B[k+1]$ for all $k \in\{0,1, \ldots, n-2...
2 2 votes
1 1 answer
386
386 views
Even though there are two for loops some times the Time complexity will be the m+n and some times it will be m*n assuming loops run till m and n respectively.How do we di...
3 3 votes
1 answers 1 answer
651
651 views
Can Somebody help me solve these recurrences?What is the method generally employed to solve questions of this type?Taken from https://jeffe.cs.illinois.edu/teaching/algor...
1 1 vote
1 1 answer
1.2k
1.2k views
Time complexity to find the diameter of a binary tree having $n$ nodes is$O\left(n^{2}\right)$$O(n)$$O(1)$$O(\log n)$
3 3 votes
1 1 answer
944
944 views
The asymptotic complexity of 4 functions $f_{1}, f_{2}, f_{3}, f_{4}$ are$f_{1}(n)=2^{n}$$f_{2}(n)=n^{(3 / 2)}$$f_{3}(n)=n \log n$$f_{4}(n)=n^{(\log n)}$Arrange them in i...
3 3 votes
2 answers 2 answers
1.1k
1.1k views
The complexity of matrix multiplication of two matrices A and B whose orders are $\mathrm{m} \times \mathrm{n}$ and $\mathrm{n} \times \mathrm{p}$ respectively is$\mathrm...
1 1 vote
1 1 answer
290
290 views
What is the time complexity of T(n) = T(n/2) + n*(2-cos n)Also try to apply master theorem (Cormen version).
0 0 votes
3 3 answers
607
607 views
Let $A=\left\{a_{1}, a_{2}, \ldots, a_{n}\right\}$ and $B=\left\{b_{1}, b_{2}, \ldots b_{m}\right\}$ be two sorted arrays of $n$ and $m$ numbers, respectively. Devise an ...
0 0 votes
1 1 answer
692
692 views
What is the time complexity of code given?def fun(n): count = 0 i = n while i>0 : for j in range(i): count += 1 i //= 2 return count$\Theta(\log n)$$\Theta(n)$$\Theta(n \...
1 1 vote
2 2 answers
464
464 views
Consider $\text{Iterated logarithm}$ of $n,$ written $\log^\ast n$ (usually read "$\log$ star $n$"), is the number of times the logarithm (base $2$) function must be iter...
5 5 votes
1 1 answer
491
491 views
Consider the following $\text{C}$ function:def fun1(n): q = 0 for i in range(1, n): p = 0 j = n while j 1: p += 1 j = j // 2 k = 1 while k < p: q += 1 k = k * 2 return q...
6 6 votes
2 2 answers
508
508 views
What will be the time complexity of following code?def mystery(N): i = 1 s = 1 while s <= N: i += 1 s = s + i$\Theta(\sqrt{N})$$\Theta(N)$$\Theta(\log N)$$\Theta\left((\l...