Hi All
I am trying to be familiar with the complexity evaluation of algorithms. In general I think that is a good/elegant practice, but in the specific I need it to express time complexity of my C++ code.
I have a small doubt. Suppose I have an algorithm that just reads data from the beginning of a std::vector
until the end; then it does the same starting from the end to beginning (so are 2 cycles for indexes "From 0 To N" followed by "From N To 0" ).
- I said to myself that the complexity for this stuff is
O( 2N )
: is this correct? - Once I reached the beginning, suppose that I want to start reading again all data from beginning to the end ( passing in total 3 times the vector ): is the complexity
O(3N)
?
It is maybe a stupid doubt, but I would like to have someone opinion anyway about my thinking process.
Kind Regards Afg