152 views
What is the time & space complexity of this algorithm?

Main()

{

for(i=n; i>10; i=i^1/4)

{

for(j=201; j<n^3; j=j+400)

{

for(k=47; k<=n^84; k=k*108)

{

k=k^61;

}

}

}

}

Ans

Perfect👍

can you explain this  (47)^61^k.

I got till (47)^61 but how k. just confused.

ohhh .. i think it would be better to take some different variable there.

I got confused between variable k and that k :)

@Pranavpurkar if you know hindi then see k^61 yha k ka value 47 dia hua h that is called initialization now k^61 ye bar bar repeat hoga due to loop to kitna bar power 61 repeat hoga whi value dega k...isi lie 61^k lie h hum. aur whi value nikale h that is called complexity(looping).

YES i got that!

I m getting

time complexity = O(n^3*logn*loglogn)

and

space complexity = O(1)

please explain in details with base & power.

I mistakenly assumed the constraint in the last loop as k<=n^84

is it k or j?

sorry it is k @Pranavpurkar

Yup I have shared my approach!

This is my approach!

EDIT:

so we have to neglect k*108

Nisha Bharti

ohhh!! got it.

yes it seems correct reason.

Nisha Bharti

this question was really good :)

1
242 views