Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

What is the worst case run time complexity of the following function?

long function(int x)

{

if(x <= 0) return 1;

else{ return 4 * function(x - 1); }

}

1 Answer

Relevance
  • Chris
    Lv 7
    4 years ago

    I'm not a big O notation expert, but since this is a recursive function for calculating powers of 4, the run time complexity is always O(n) I guess, at least for x > 0.

    The worst case is basically the expected functionality, as far as I can see.

Still have questions? Get your answers by asking now.