### big-o

#### Why this code gives big-O = O(1)

public static LinkedList third(int[] array){ LinkedList retval = null; for (int i = 0; i < 999 && i < array.length; i = i + 1) { retval = new LinkedList(array[i], retval); } return retval; } Why this code gives big-O = O(1) ?

Because the loop will be executed maximally 999 times which is a constant value therefore You can think of it as it's O(999) = O(1) = O(c), where c is a constant value. If the value of i wouldn't be limited by 999, the loop would be executed array.length times and the complexity would be O(n), where n is the size of input array.

### Related Links

What is growth function and order where inner loop variable is multiplied by 2

Big O time complexity for nested j = i + 1 loop

How to calculate the running time of this algorithm?

Big-O Notation and coding

Either f(n) = O(g(n)) or g(n) = O(f(n))

Is an algorithm with asymptotic runtime complexity of θ(n) always faster runtime than a similar algorithm with runtime complexity of θ(n^2 )?

Best case of quick sort variation

Big O - Nested loops

Is the big o for the following O(n^2*log(n)) or O(n^3*log(n))

Confusion around Big-O with natural logs [closed]

Building a recurrence relation for this code?

Usage of Little-O notation

time complexity of the following algorithm

What is the Big O for the difference of two sorted lists [closed]

Big Oh Classification [closed]

Prove max(O(f(n)), O(g(n)))=O(max(f(n), g(n))