Results 1 to 2 of 2
  1. #1
    hjxlpp is offline Member
    Join Date
    May 2013
    Posts
    17
    Rep Power
    0

    Question time complexity about 3^n using nested for loop

    Hi, everyone. Anybody can show me how to write a nested for loop about 3^n?

    Thanks!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,733
    Blog Entries
    7
    Rep Power
    21

    Default Re: time complexity about 3^n using nested for loop

    Sure, have a look:

    Java Code:
    void bigOh(int n) {
       int t= (int)Math.pow(3, n);
       for (int o= 1; o == 1; o++) // outer loop
          while (t-- > 0); // nested loop
    }
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Time complexity question
    By romavolman in forum Advanced Java
    Replies: 8
    Last Post: 09-19-2012, 07:41 PM
  2. I need help with Time Complexity???
    By lulzim in forum Advanced Java
    Replies: 2
    Last Post: 09-20-2011, 10:11 AM
  3. I need help for Time Complexity of this???
    By lulzim in forum Advanced Java
    Replies: 9
    Last Post: 09-16-2011, 04:51 PM
  4. Time complexity - foor loop
    By hawaiifiver in forum New To Java
    Replies: 5
    Last Post: 02-05-2011, 05:06 PM
  5. time complexity questions
    By myst in forum New To Java
    Replies: 6
    Last Post: 07-13-2010, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •