We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This my friend, is not O(n/2). Think of it this way, you are reading al lthe elements in the data set. That is what determines O(). The style of looping is not really a determining factor.
Moreover, O(N/2) is simply O(0.5N) and that is ignored. This notation does not care about the constant. So, a complexity of O(N) and O(10^4N) and O(0.0003N) is all the same- O(N).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →
This my friend, is not O(n/2). Think of it this way, you are reading al lthe elements in the data set. That is what determines O(). The style of looping is not really a determining factor.
Moreover, O(N/2) is simply O(0.5N) and that is ignored. This notation does not care about the constant. So, a complexity of O(N) and O(10^4N) and O(0.0003N) is all the same- O(N).