WHY we say the time complexity of reading element in a Array is O(1)? There is only once operation? What's it? WHY?
i am thinking, there are many built-in method in .Net library, how we define if it is a basic operation when we check the time complexity?
Loading

VulpesRank #55 · 29.2K reputationPosted Sep 19, 2011, 1:59 AM EDT
Satish BhatRank #2,496 · 563 reputationPosted Sep 19, 2011, 2:18 AM EDT
MSDN says Array.GetValue Method is an O(1) operation.
Whereas Array.Find(T) Method is an O(n) operation, where n is the Length of array.
VulpesRank #55 · 29.2K reputationPosted Sep 19, 2011, 2:56 AM EDT
Reading an array element in 'safe' code does much the same thing under the hood though the code will check that 'n' is not outside the bounds of the array first.