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
VulpesPosted Sep 19, 2011, 5:59 AM
VulpesPosted Sep 19, 2011, 6:56 AM
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.
Satish BhatPosted Sep 19, 2011, 6:18 AM
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.