Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged time-complexity
0
votes
0
answers
661
Algo: Time Complexity
What is the time complexity of the following piece of code in the terms of n? $Main()$ { $n=2^{2^k};$ $for(i=1; i<=n; i++)$ { $j=2;$ $while(j<=n)$ { $j=j^2;$ } } }
What is the time complexity of the following piece of code in the terms of n?$Main()${$n=2^{2^k};$$for(i=1; i<=n; i++)${ $j=2;$ $while(j<=n)$ { $j=j^2;$ }}...
pbhati
342
views
pbhati
asked
Jun 12, 2018
Algorithms
algorithms
time-complexity
+
–
3
votes
1
answer
662
Extended Master's Theorem $T(n)=n^{1/2}T(n^{1/2})+n$
Can Extended Masters theorem be applied to the following recursive equation ? $T(n)=n^{1/2}T(n^{1/2})+n$ I solved this using back substitution and the time complexity came out to be $O(n*(loglogn))$ I was wondering if this ... masters theorem, like the way Tauhin Gangwar has solved here - https://gateoverflow.in/60532/find-tc-t-n-2t-n-1-2-1
Can Extended Masters theorem be applied to the following recursive equation ?$T(n)=n^{1/2}T(n^{1/2})+n$I solved this using back substitution and the time complexity came ...
Hardik Maheshwari
3.7k
views
Hardik Maheshwari
asked
Jun 11, 2018
Algorithms
time-complexity
algorithms
master-theorem
asymptotic-notation
recurrence-relation
+
–
0
votes
3
answers
663
Time Complexity
What is the time complexity of the following code? for(i=n;i>=1;) i=i/2;
What is the time complexity of the following code?for(i=n;i>=1;)i=i/2;
Devshree Dubey
401
views
Devshree Dubey
asked
Jun 10, 2018
Algorithms
algorithms
time-complexity
+
–
1
votes
0
answers
664
GATE Suitability Test | Test 1 | Question: 6
The total number of function calls, time complexity and the return value of the following function respectively are int foo(int n) { int j,sum = 0,mycount=0;; if(n <= 0) return 0; sum += n + foo(n-1); for(j = 0; j < n*n*n; j++) mycount += j; return ... $\Theta(n^2), \Theta(n^5), \Theta(n^4)$ $\Theta(n), \Theta(n^5), \Theta(n^4)$
The total number of function calls, time complexity and the return value of the following function respectively areint foo(int n) { int j,sum = 0,mycount=0;; if(n <= 0) r...
Arjun
165
views
Arjun
asked
Jun 10, 2018
Algorithms
gate-suitability-test-1
time-complexity
+
–
0
votes
3
answers
665
Self-Doubt
int main() { int i; for(i=1;i<=n;i++) f(i); } void f(int n) { int A[n]; int j; for(j=1;j<=n;j++) cout<<j; } What will be the time and space complexity of the following code snippet ?
int main() { int i; for(i=1;i<=n;i++) f(i); } void f(int n) { int A[n]; int j; for(j=1;j<=n;j++) cout<<j; }What will be the time and space complexity of the following cod...
Phlegmatic
527
views
Phlegmatic
asked
Jun 8, 2018
Algorithms
algorithms
time-complexity
space-complexity
+
–
1
votes
2
answers
666
Cormen
T(n)=T(n-1)+2n where T(1)=1 Solve recurrence relation
T(n)=T(n-1)+2n where T(1)=1Solve recurrence relation
vijju532
3.2k
views
vijju532
asked
Jun 8, 2018
Algorithms
recurrence-relation
algorithms
time-complexity
+
–
0
votes
0
answers
667
Complexity
#DAA Prove that if: f(n) = amnm + am-1nm-1 + am-2nm-2 + am-3nm-3 + .........+ a1n + a0 then f(n) = O(nm) .
#DAAProve that if: f(n) = amnm + am-1nm-1 + am-2nm-2 + am-3nm-3 + .........+ a1n + a0 then f(n) = O(nm) .
Naveen Kumar 3
258
views
Naveen Kumar 3
asked
Jun 6, 2018
Algorithms
algorithms
time-complexity
asymptotic-notation
+
–
1
votes
2
answers
668
Analysis of algorit
Which of the following statements is/are valid? 1. Time Complexity of QuickSort is Θ(n^2) 2. Time Complexity of QuickSort is O(n^2) 3. For any two functions f(n) and g(n), we have f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = Ω(g(n)). 4. Time complexity of all computer algorithms can be written as Ω(1)
Which of the following statements is/are valid?1. Time Complexity of QuickSort is Θ(n^2)2. Time Complexity of QuickSort is O(n^2)3. For any two functions f(n) and g(n), ...
jatinkumar
2.6k
views
jatinkumar
asked
Jun 6, 2018
Algorithms
time-complexity
algorithms
asymptotic-notation
multiple-selects
+
–
1
votes
1
answer
669
Sorting
Which sorting algorithm is good if we already knew the range of number - Counting Sort OR Radix Sort
Which sorting algorithm is good if we already knew the range of number -Counting Sort OR Radix Sort
jatinkumar
849
views
jatinkumar
asked
Jun 5, 2018
DS
sorting
time-complexity
algorithms
+
–
1
votes
2
answers
670
Made easy test series
saumya mishra
589
views
saumya mishra
asked
May 30, 2018
Algorithms
made-easy-test-series
time-complexity
+
–
7
votes
3
answers
671
Time complexity , Recursion
Why is recursive equation of following code $T(n)=T(n/2)+O(1)$, not $T(n)=8*T(n/2)+O(1)$? int x=0; int A(n) { if(n==1) return 1; else { X+=8A(n/2)+n^3; } return X; }
Why is recursive equation of following code $T(n)=T(n/2)+O(1)$, not $T(n)=8*T(n/2)+O(1)$? int x=0; int A(n) { if(n==1) return 1; else { X+=8A(n/2)+n^3; } return X; }
bts
1.9k
views
bts
asked
May 29, 2018
Algorithms
recursion
time-complexity
algorithms
master-theorem
+
–
1
votes
1
answer
672
Dijkstra Time Complexity using Binary Heap
Question Source - https://gateoverflow.in/1374/gate2005-38 Let G(V,E)be an undirected graph with positive edge weights. Dijkstra's single source shortest path algorithm can be implemented using the binary heap data structure with time complexity: 1. O(|V|2) 2. O(| ... as I > said the correct answer is O((|E|+|V|)log|V|). So, where am I going > wrong?
Question Source - https://gateoverflow.in/1374/gate2005-38Let G(V,E)be an undirected graph with positive edge weights. Dijkstra’s single source shortest path algorithm ...
iarnav
2.5k
views
iarnav
asked
May 22, 2018
Algorithms
algorithms
binary-heap
dijkstras-algorithm
time-complexity
+
–
0
votes
2
answers
673
Finding Kth Smallest Element
Which one of the following is the recurrence equation for the worst case time complexity of finding Kth smallest element in an array of size n' using partition function? Assume c' is constant. A. T(n) = 2T(n/2) + c . n B. T(n) = 2T(n - 1) + c C. (n ... ) + c . n D. T(n) = T(n/2) + c . n Explanation Please and please tell me the different ways we can solve this problem
Which one of the following is the recurrence equation for the worst case time complexity of finding Kth smallest element in an array of size ‘n’ using partition func...
Na462
2.6k
views
Na462
asked
May 20, 2018
Algorithms
algorithms
recurrence-relation
time-complexity
+
–
0
votes
1
answer
674
Time complexity
Which of the following sorting algorithm has almost the same worst case and best case complexity? 1- Quick Sort 2- Merge Sort 3- Shell Sort 4- Heap Sort PS: Is it heap or shell, I am confused. Please clarify me.
Which of the following sorting algorithm has almost the same worst case and best case complexity?1- Quick Sort2- Merge Sort3- Shell Sort4- Heap Sort PS: Is it heap or sh...
Shumile
4.5k
views
Shumile
asked
May 18, 2018
Algorithms
time-complexity
+
–
1
votes
1
answer
675
Time complexity
show how to sort n number in the range [0,n^2-1] in O(n)time?
show how to sort n number in the range [0,n^2-1] in O(n)time?
once_2019
313
views
once_2019
asked
May 8, 2018
Algorithms
time-complexity
algorithms
+
–
1
votes
1
answer
676
Evaluation of Postfix expression using stack
What is time and space complexity to evaluate postfix expression ?
What is time and space complexity to evaluate postfix expression ?
JaiKumar Guwalani
2.8k
views
JaiKumar Guwalani
asked
May 6, 2018
DS
data-structures
time-complexity
space-complexity
infix-prefix
stack
+
–
2
votes
0
answers
677
Algorithm
You have an array A with n JPEG images some of which are identical. You can check if two objects are equal but you cannot compare them in any other way-i.e. you can check A[i] == A[j] and A[i] != A[j], but comparisons such as A[i] < A[j] ... of its elements are equal to each other. Use divide and conquer to come up with an O(n logn ) algorithm to determine if A has a majority element.
You have an array A with n JPEG images some of which are identical.You can check if two objects are equal but you cannot compare them in any other way—i.e. you can chec...
Kushagra Chatterjee
930
views
Kushagra Chatterjee
asked
May 2, 2018
Algorithms
algorithms
time-complexity
divide-and-conquer
+
–
0
votes
1
answer
678
Data structure
What is the running time of the function? Int function(int n) { If(n<=1)return; For(int i=1;i<n;i++); For(int j=0;j<3;j++); Function (n-1);
What is the running time of the function?Int function(int n) {If(n<=1)return;For(int i=1;i<n;i++);For(int j=0;j<3;j++);Function (n-1);
Pramod Sharma 1
298
views
Pramod Sharma 1
asked
Apr 30, 2018
Programming in C
time-complexity
+
–
3
votes
1
answer
679
time complexity
$f(n)=2n^2+ n log n$ $g(n)= \dfrac{n}{logn} + log^2n$ then $f(n)\times g(n)$ is: $n^2logn$ $\dfrac{n^3}{logn}$ $n^3log^2n$ $n^2log^2n$
$f(n)=2n^2+ n log n$$g(n)= \dfrac{n}{logn} + log^2n$ then $f(n)\times g(n)$ is:$n^2logn$$\dfrac{n^3}{logn}$$n^3log^2n$$n^2log^2n$
sumit_kumar
284
views
sumit_kumar
asked
Apr 30, 2018
Algorithms
time-complexity
algorithms
+
–
0
votes
1
answer
680
Time Complexity
int lcs_length(char * A, char * B) { if (*A == '\0' || *B == '\0') return 0; else if (*A == *B) return 1 + lcs_length(A+1, B+1); else return max(lcs_length(A+1,B), lcs_length(A,B+1)); } what is worst case time complexity of $\text{lcs_length}$ if size of $A$ is $m$ and size of $B$ is $n$? O($2^{m+n}$) O($2^{n}$) O($2^{mn}$) O($2^{max(m,n)}$) none of these
int lcs_length(char * A, char * B) { if (*A == '\0' || *B == '\0') return 0; else if (*A == *B) return 1 + lcs_length(A+1, B+1); else return max(lcs_length(A+1,B), lcs_le...
hacker16
413
views
hacker16
asked
Apr 28, 2018
Algorithms
time-complexity
recursion
algorithms
+
–
0
votes
1
answer
681
Doubt on Heap
How much time will it take for deleting $i^{th}$ and a number $n(random)$ node from a heap?
How much time will it take for deleting $i^{th}$ and a number $n(random)$ node from a heap?
Akash Kumar Roy
1.0k
views
Akash Kumar Roy
asked
Apr 28, 2018
DS
data-structures
binary-heap
time-complexity
+
–
1
votes
1
answer
682
Time Complexity
Please find the time complexity of the following code:-int i,s1; i=1,s1=1; while(s1<=n) { i++; s1+=s1+i; printf("Hope"); }
Please find the time complexity of the following code:-int i,s1;i=1,s1=1; while(s1<=n) { i++; s1+=s1+i; printf("Hope"); }
Devshree Dubey
4.4k
views
Devshree Dubey
asked
Apr 27, 2018
Algorithms
algorithms
time-complexity
+
–
6
votes
3
answers
683
ISRO2018-37
The running time of an algorithm is given by: $T(n) = T(n-1) + T(n-2) - T(n-3)$, if $n > 3$ = $n$, otherwise Then what should be the relation between $T(1), T(2), T(3)$, so that the order of the algorithm is constant? $T(1) = T(2) = T(3)$ $T(1) + T(3) = 2T(2)$ $T(1) - T(3) = T(2)$ $T(1) + T(2) = T(3)$
The running time of an algorithm is given by: $T(n) = T(n-1) + T(n-2) - T(n-3)$, if $n 3$ = $n$, otherwiseThen what...
Arjun
7.6k
views
Arjun
asked
Apr 22, 2018
Algorithms
isro2018
algorithms
recurrence-relation
time-complexity
+
–
3
votes
4
answers
684
ISRO2018-56
The time complexity of computing the transitive closure of binary relation on a set of $n$ elements is known to be $O(n)$ $O(n*\log(n))$ $O(n^{\frac{3}{2}})$ $O(n^{3})$
The time complexity of computing the transitive closure of binary relation on a set of $n$ elements is known to be$O(n)$$O(n*\log(n))$$O(n^{\frac{3}{2}})$$O(n^{3})$
Arjun
2.2k
views
Arjun
asked
Apr 22, 2018
Set Theory & Algebra
isro2018
set-theory&algebra
relations
time-complexity
+
–
5
votes
2
answers
685
ISRO2018-72
Consider the following C code segment int f(int x) { if(x<1) return 1; else return (if(x-1)+g(x)); } int g(int x) { if(x<2) return 2; else return (if(x-1)+g(x/2)); } Of the following, which best describes the growth of $f(x)$ as a function of $x$ ? Linear Exponential Quadratic Cubic
Consider the following C code segmentint f(int x) { if(x<1) return 1; else return (if(x-1)+g(x)); } int g(int x) { if(x<2) return 2; else return (if(x-1)+g(x/2)); }Of the...
Arjun
4.6k
views
Arjun
asked
Apr 22, 2018
Algorithms
isro2018
algorithms
identify-function
time-complexity
+
–
3
votes
2
answers
686
#Graph Theory #Algorithms Self Doubt about Dense Graphs.
Please give some example regarding number of edges in dense graph is - |E| < |V2| I get that when we take log both sides we get O(ElogV), but I can't get this |E| < |V2|
Please give some example regarding number of edges in dense graph is - |E| < |V2|I get that when we take log both sides we get O(ElogV), but I can't get this |E| < |V2|
iarnav
757
views
iarnav
asked
Apr 21, 2018
Algorithms
algorithms
graph-algorithms
time-complexity
+
–
0
votes
1
answer
687
#Algorithms How is this equivalent in Kruskal's Algorithm's Time Complexity?
Kruskal Time complexity is O(mlog m) then how in upper bound it can be written as - O(m2) ----> How log m = O(m) and O (mn) ---------> How log n = O(n)
Kruskal Time complexity is O(mlog m) then how in upper bound it can be written as - O(m2) How log m = O(m)and O (mn) - How log n = O(n)
iarnav
1.5k
views
iarnav
asked
Apr 21, 2018
Algorithms
algorithms
time-complexity
graph-algorithms
+
–
3
votes
1
answer
688
Coreman :Graph Algorithms
The square of a directed graph G=(V,E) is the graph G2=(V,E2) such that (u,v) ∈ E2 if and only G contains a path with at most two edges between u and v. Describe efficient algorithms for computing G2 from G for both the adjacency-list and adjacency-matrix representations of G. Analyze the running times of your algorithms.
The square of a directed graph G=(V,E) is the graph G2=(V,E2) such that(u,v) ∈ E2 if and only G contains a path with at most two edges between u and v.Describe efficien...
Abhishek Malik
1.4k
views
Abhishek Malik
asked
Apr 16, 2018
Algorithms
graph-algorithms
cormen
time-complexity
+
–
0
votes
1
answer
689
time complexity
Beyonder
583
views
Beyonder
asked
Apr 11, 2018
Algorithms
time-complexity
algorithms
asymptotic-notation
programming-in-c
test-series
+
–
1
votes
1
answer
690
#Algorithms MST Question Doubt
Let G be a weighted connected undirected graph with distinct positive edge weights. If every edge weight is decreased by the same value (constraint is - keeping all edge positive all the time), then is it TRUE or FALSE? Shortest path between any pair of vertices does not change?
Let G be a weighted connected undirected graph with distinct positive edge weights. If every edge weight is decreased by the same value (constraint is - keeping all edge ...
iarnav
958
views
iarnav
asked
Apr 11, 2018
Algorithms
algorithms
time-complexity
minimum-spanning-tree
+
–
Page:
« prev
1
...
18
19
20
21
22
23
24
25
26
27
28
...
53
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register