Results 1 to 8 of 8
Thread: Time complexity of ThreeToTheN
 06252013, 03:54 PM #1Member
 Join Date
 Jun 2013
 Posts
 62
 Rep Power
 0
Time complexity of ThreeToTheN
Write a class, called ThreeToTheN with a method with the signature:
public void run(int n);
which takes running time in proportion to 3n. Note, your run method does not need to produce any output or do anything else. It just needs to take the appropriate number of operations to run.
If it helps with your solution, you are allowed to define additional methods in the class.
 06252013, 03:55 PM #2
Re: Time complexity of ThreeToTheN
What have you tried?  Matt Gemmell
Post your code and ask specific questions. Nobody will do your homework for you.Math problems? Call 1800[(10x)(13i)^2][sin(xy)/2.362x]
The Ubiquitous Newbie Tips
 06252013, 03:58 PM #3Member
 Join Date
 Jun 2013
 Posts
 62
 Rep Power
 0
Re: Time complexity of ThreeToTheN
from what i know,
somehow got this code for 2^N
Java Code:public class FibMemMatch { public void run(int n){ int a=0, b=1; for(int i=0; i<n; i++) { int c = a; a = b; b = c + b; } System.out.println(a); } }
Last edited by Malv; 06252013 at 04:15 PM.
 06252013, 04:02 PM #4Member
 Join Date
 Jun 2013
 Posts
 62
 Rep Power
 0
Re: Time complexity of ThreeToTheN
I've try out codes like this
Java Code:public class ThreeToTheN { public void run(int n){ int t= (int)Math.pow(3, n); for (int o= 1; o == 1; o++) // outer loop while (t > 0); // nested loop } }
Last edited by Malv; 06252013 at 04:15 PM.
 06252013, 04:09 PM #5
Re: Time complexity of ThreeToTheN
Use BigInteger then.
Math problems? Call 1800[(10x)(13i)^2][sin(xy)/2.362x]
The Ubiquitous Newbie Tips
 06252013, 04:13 PM #6Member
 Join Date
 Jun 2013
 Posts
 62
 Rep Power
 0
Re: Time complexity of ThreeToTheN
BigInteger belongs to Math.class
java.Math.BigInteger
 06252013, 04:16 PM #7
Re: Time complexity of ThreeToTheN
Then implement your own pow method.
Math problems? Call 1800[(10x)(13i)^2][sin(xy)/2.362x]
The Ubiquitous Newbie Tips
 06252013, 05:12 PM #8
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,783
 Blog Entries
 7
 Rep Power
 21
Similar Threads

How to write the time complexity about n!
By hjxlpp in forum New To JavaReplies: 1Last Post: 06232013, 11:05 AM 
time complexity of toArray
By marcosol in forum New To JavaReplies: 13Last Post: 09192012, 07:51 PM 
Time complexity question
By romavolman in forum Advanced JavaReplies: 8Last Post: 09192012, 07:41 PM 
I need help with Time Complexity???
By lulzim in forum Advanced JavaReplies: 2Last Post: 09202011, 10:11 AM 
I need help for Time Complexity of this???
By lulzim in forum Advanced JavaReplies: 9Last Post: 09162011, 04:51 PM
Bookmarks