I'm fairly new to complexity measures, please bear with.
I understand the following complexity examples:
O(n) - Linear Time
Example:
std::vector<int> MyV={1,4,6,2,9};
std::for_each(MyV.begin(), MyV.end(), [](int e1, int e1){return e1<e2;});
//I.e. n of operations based on the number of elements
O(1) - Constant Time
Example:
for(int i=5; i--;)
{
//Do Stuff
}
//i.e. n of operations will be 5
O(n2) - Quadratic Time
Example:
std::vector<int> MyVec_A={1,2,3,4,5};
std::vector<int> MyVec_B={1,2,3};
for(int i=MyVec_A; i--;)
{
for(int x=MyVec_B; x--;)
{
//Do Stuff
}
}
Are the above example correct?
If not, could you provide some pointers as to how I can correct the examples?
I'm also unsure of Logarithmic time O(log n), an example would be really helpful?