Running Time Complexity of O (n / 2)
问题 I once understood this but not anymore. Lets say I have an algorithm that will return the number in the middle of an array. for (int i = 0; i < nums.length; i++) { if (i == nums.length / 2) return nums[i]; } The worst case of this will always be O (n / 2) right? There is no worse case than this. But how come we just conclude that it is O(n) ? 回答1: Big O time complexity is not about measuring the actual time an algorithm will take, it instead specifies what variables the time complexity is