I'm trying to gain a better understanding of Big O.
Here is something that I'm unsure about. Say we have an array containing N elements that is inputted by the user. From my understanding iterating over each element from this array gives O(n) as we are looping over the array N times.
Now we do the same thing, we iterate over the array N times but only store, for example the number 3 from the array, into another array. Which we then loop over that array. What would the full equation for this algorithm or is it the case that the final result will always be O(n) and so we can completely ignore the rest?
Example:
firstArray = [1,1,1,2,2,2,2,3,3,3,6,7,8]
secondArray = []
for i=0 to firstArray.length()
secondArray.add(firstArray[i])
for i=0 to secondArray.length()
secondArray[i] += 10
print(secondArray[i])
What confuses me is how we represent the second array, as it can be different each time the code is executed.