# What is the best way to calculate Big O?

```
int array[n];
```

```
x = array[0];
```

```
for(int i = 0; i < n; i++){
if(array[i] == numToFind){ return i; }
}
```

```
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
array[j] += 2;
}
}
```

Tags: algorithm optimization performance complexity-theory big-o

Source: By sven as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 4.0

##### Related code-snippets:

- How can I get the value of in a loop?
- Anatomy of a memory leak -'memory leak'
- Function for creating color wheels.
- What is the most efficient code for 10000 prime numbers?
- How can I create an object instance from a Type?
- How can we efficiently get sorted sums of a sorted list?
- How is database indexing used?
- What is the most efficient graph data structure in Python?
- "Sorting" colors by distinctiveness. Followup:
- Data verifications in Getter or elsewhere?
- Graph serialization is a form of graph serialization.
- I am doing some project with CSharpCodeProvider Compilation Performance. The code provided is compilable from scratch. How should I modify my code?
- What's a quicker way to find duplicates conditioned by time?
- Is String.Format more efficient than StringBuilder?
- Performance Considerations for throwing Exceptions