In computer science, the time complexity is the computational complexity that describes the amount of time it takes to run an algorithm.
Big O: Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. To put it in a simple terms big O describes the performance of an algorithm.
Array
Lookup by Index | O(1) |
Lookup by Value | O(n) |
Insert | O(n) |
Delete | O(n) |
Linked List
Lookup by value | O(n) |
Lookup by Index | O(n) |
Insert at the beginning | O(1) |
Insert at the middle | O(n) |
Insert at the end | O(1) |
Delete at the beginning | O(1) |
Delete at the middle | O(n) |
Delete from the end | O(n) |
Stack
push | O(1) |
pop | O(1) |
peek | O(1) |
isEmpty | O(1) |
Queue
Enqueue | O(1) |
Dequeue | O(1) |
Peek | O(1) |
isEmpty | O(1) |
isFull | O(1) |