what is the complexity of a program having only one loop, is it log n? can someone give me some ideas about estimating complexity of codes?
If it is Big-O time complexity you are asking about, then for loop it is n
times complexity of whatever is within the loop, where n
is loop count limit.
So. if the code inside loop is taking constant time to execute, i.e. if its time complexity is O(1), then the complexity of the loop will be O(1*n) = O(n).
In the similar way, if within the loop you have another loop which will make m
steps, then your entire code is O(n*m), and so on.