I'm implementing a priority queue and want to iterate through the list to insert at the right spot. In the documentation it states that C# List<T>.Item
Property is O(1): List<T>.Item
Property
e.g.
int retrivedValue = myIntList[5];
How is this possible since add also is O(1)? It's like eating the cookie and still have it. Normal lists in my head have O(n) for accessing an element.
The standard List type is backed by an internal array with O(1) access performance.
List does not use a linked list implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With