Can someone help with big O notation?

Posted by Dann on Stack Overflow See other posts from Stack Overflow or by Dann
Published on 2010-04-25T19:50:06Z Indexed on 2010/04/25 19:53 UTC
Read the original article Hit count: 226

Filed under:
|
|
|
void printScientificNotation(double value, int powerOfTen)
{
if (value >= 1.0  &&  value < 10.0)
{
    System.out.println(value + " x 10^" + powerOfTen);
}
else if (value < 1.0)
{
    printScientificNotation(value * 10, powerOfTen - 1);
}
else     // value >= 10.0
{
    printScientificNotation(value / 10, powerOfTen + 1);
}

}

I understand how the method goes but I cannot figure out a way to represent the method. For example, if value was 0.00000009 or 9e-8, the method will call on printScientificNotation(value * 10, powerOfTen - 1); eight times and System.out.println(value + " x 10^" + powerOfTen); once.

So the it is called recursively by the exponent for e. But how do I represent this by big O notation?

Thanks!

© Stack Overflow or respective owner

Related posts about recursion

Related posts about big