in Algorithms retagged by
152 views
0 votes
0 votes
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;

                              }

                  }

      }

}
in Algorithms retagged by
152 views

3 Answers

1 vote
1 vote

Ans

4 Comments

Perfect👍

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

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

1
1

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

I got confused between variable k and that k :)

0
0

@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).

0
0

YES i got that!

1
1
0 votes
0 votes

I m getting

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

and

space complexity = O(1)

4 Comments

please explain in details with base & power.
0
0

.

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

is it k or j?

0
0

sorry it is k @Pranavpurkar

0
0
Yup I have shared my approach!
0
0
0 votes
0 votes

This is my approach!

EDIT: 

This answer has mistakes :(

edited by

4 Comments

so we have to neglect k*108
0
0

Nisha Bharti

ohhh!! got it.

yes it seems correct reason.

0
0

Nisha Bharti

this question was really good :)

1
1

Related questions