1,121 views

3 Answers

Best answer
1 1 vote
0(n^3) because the internal loop runs n^3 times and now it does not satisfy the condition of 1st and 2nd loop so it comes out of the loop
selected by
0 0 votes
answer is n^3 since

for first loop i =1

second loop i=1

third will run i=n^3 now when it goes back to second it compares & fails since i has changed to n^3 so it will be transfer to first loop again fail coz i = n^3 so only one time loop will execute

so O(n^3)
0 0 votes

First of all the variable  ' i ' is not initialised. If  ' i '  is declared outside all the for loops then the time complexity will be O(n3).  But instead if you are declaring  i each time inside a loop then time complexity will be O(n6).

So basically the complexity depends on the scope of the variable i. 

Position:
Show:

Related questions

2 2 votes
1 1 answer
150
150 views
GO Classes asked Aug 31
150 views
The algorithm $\text{ALGSORT}$ sorts an array of distinct integers using comparisons.The function $\text{MININDEX(V,i,j)}$ returns the position of the smallest element in...
1 1 vote
1 1 answer
104
104 views
GO Classes asked Aug 29
104 views
Suppose Huffman coding is implemented as follows.Initially, the $n$ symbols are stored in a min priority queue according to their frequencies.The algorithm repeatedly per...
0 0 votes
1 1 answer
84
84 views
GO Classes asked Aug 26
84 views
Consider,f1(N): x = 0 for i = 0 to N - 1: x++ return xand,f2(N, R): x = 0 for i = 0 to N - 1: for j = 1; j <= R; j = j + j: x = x + f1(j) return xWhat is the order of gro...
0 0 votes
0 0 answers
309
309 views
Vennapusa_Gurunath_r asked Dec 12, 2024
309 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...