0

What is the recurrence equation for this function?

i <- n
while ( i > 1){
   j <- i
   while ( j < n){
      k <- 0
      while (k < n){
         k = k +2;
      }
      j <- j * 2;
   }
   i <- i / 2;
}

I guess, T(n) =T(n^2/4) + 2/n. or T(n) = M*T(n^2/4) + 2/n

Am I right to guess?

I think something's gonna have to come to M, but I'm not sure.

gowoo
  • 11
  • 1
  • If you don't have recursive function calls, you don't get a recurrence equation. – Jakube Oct 18 '20 at 11:13
  • We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. – D.W. Oct 18 '20 at 18:12
  • The claim "If you don't have recursive function calls, you don't get a recurrence equation." is nonsense. You can get a recurrence equation whenever you like or need to get one in order to solve a counting problem. – plop Oct 18 '20 at 22:33

0 Answers0