I'm working on understanding big O notation a little bit better and got stumped on this problem in class.
If I had a for loop with a constant number of iterations that simply prints something to the console on each iteration:
for(int i=1; i<10; i++)
{
cout << "Hello!" << endl;
}
What would the big O notation for this snippet of code be? The line that writes to the console takes 1 unit of time, and I would multiply this by the number of times it would be executed - in this case 10 - so I would get O(10). However, this just reduces to O(1).
Is this a correct analysis?