Big Oh Expression in Java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ikorn
    New Member
    • Nov 2006
    • 1

    #1

    Big Oh Expression in Java

    Can someone help me with this
    Consider the Java program fragments given below. Assume that n, m, and k are non-negative ints and that the method e and f have the following characteristics :
    The worst case running time for e(n,m,k) is O(1) and it returns a value between 1 and (n+m+k).
    The worst case running time for f(n,m,k) is O(n+m).

    Determine a tight, big oh expression for the worst-case running time of the following program fragment:
    for (int i = 0; i < e (n, m, k); ++i)
    f (n, 10, 0);

    I think that the answer is (n+m+k)*O(1)*O( n+m)?
    Am I right?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Ikorn
    Can someone help me with this
    Consider the Java program fragments given below. Assume that n, m, and k are non-negative ints and that the method e and f have the following characteristics :
    The worst case running time for e(n,m,k) is O(1) and it returns a value between 1 and (n+m+k).
    The worst case running time for f(n,m,k) is O(n+m).

    Determine a tight, big oh expression for the worst-case running time of the following program fragment:
    for (int i = 0; i < e (n, m, k); ++i)
    f (n, 10, 0);

    I think that the answer is (n+m+k)*O(1)*O( n+m)?
    Am I right?
    how about (n+m+k)*O(1)*O( n+10)?

    Comment

    Working...