1.

What is the time complexity for performing basic operations in an array?

Answer»

The Time COMPLEXITY of different operations in an array is: For analyzing the real-time complexity you also have to CONSIDER the time in bringing the block of memory from an EXTERNAL device to RAM which takes O(√N) time.

ARRAY OPERATIONREAL TIME COMPLEXITYASSUMED TIME COMPLEXITY
Accessing the i-th element.O(√N)O(1)
Traversing all elements.O(N + √N)O(N)
OVERRIDE element at i-th index.O(√N)O(1)
Insert an element.O(N + √N)O(N)
Delete an element.O(N + √N)O(N)


Discussion

No Comment Found