Time complexity

O(N) and O(logN) complexity are not cleared ?

Hi @Chitwan,
See first clear the notation of O … O means worst case scenario . Like if you are sorting a array you do not know in which condition the element of array are … They may be already sorted … So in the case when they are in initially in such a way that every element has to be manipulated or needs to be changed is called the worst case scenario. Like the worst of all possible cases . Now the argument of O is just the number of time manipulation or change are done or in simple terms the number of times a loop run … if you have done selection sort the loop runs n times and the inner loop runs n more times so in such case time complexity is O(n^2). In a case where loop runs only logn times the complexity is O(logn) … that happens in the case of binary search … as the main array is broken into two parts at each step hence number of times a loop runs in logn

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.