Just a simple question. Is the following sample the equivalent of O(2)?
int i = 0;
int j = 0;
There are only two assignments, no loops, nested loops, comparisons or additions. It's basically O(1) + O(1), right?
Big-Oh analysis
Page 1 of 12 Replies - 1615 Views - Last Post: 19 January 2013 - 06:01 PM
Replies To: Big-Oh analysis
#2
Re: Big-Oh analysis
Posted 19 January 2013 - 05:44 PM
It's not really meaningful to speak of O(2) since constant factors do not matter in big-oh notation, so O(2) is the same thing as O(1). If a piece of code has constant running time, we say it's running time is in O(1) - no matter what the constant is.
PS: I've moved this thread to the Computer Science forum as it wasn't really about Java, but rather about big-oh notation.
PS: I've moved this thread to the Computer Science forum as it wasn't really about Java, but rather about big-oh notation.
This post has been edited by sepp2k: 19 January 2013 - 05:46 PM
#3
Re: Big-Oh analysis
Posted 19 January 2013 - 06:01 PM
I didn't realize I posted in the Java forum. Sorry about that and thanks for that clearing that up for me.
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote



|