Example & Tutorial understanding programming in easy ways.

List the different time complexity of array operations.

Time Complexity:

Construct one dimension array of size n : O(n)
Traversing one dimension array of size n: O(n)

Construct two dimension array of size n : O(n^2)
Traversing two dimension array of size n: O(n^2)

Insertion in Array : O(1)
Deletion in Array : O(n) or O(1)

Searching in unsorted Array of size n : O(n)
Searching in sorted Array of size n : O(n) or O(log(n))

Reverse Array of size n : O(n)

Sort the Array of size n : O(n^2) or O(nlogn)

Space complexity:

storing an Array of size n : O(n)




Read More →