Running time in Big O notation for Java Arrays Algorithms

Big O notation is used to classify algorithms based on how the running time and space requirements grows as the input size grows. Big O notation is represented using upper case letter ‘O’ and the meaning of this notation is “Order of”.

Running Times in Big O notation

In our previous posts (Please check Linear Search ComplexityBinary Search Complexity) we have explained how to calculate running time in Big O notation.

In Big O notation, we could say that linear search takes O(n) time, and binary search takes O(log n) time. To understand how to calculate logarithmic time please check Logarithmic time binary search.

And insertion of an element into an Unordered Array takes O(1) time i.e., constant time and deletion of an element from Unordered Array takes takes O(n) time. Similarly insertion of an element in to Ordered Array takes O(n) time and deletion of an element from Ordered Array takes O(n) time.

Arrays AlgorithmBig O Notation/ Running Time
Linear Search AlgorithmO(n)
Binary Search AlgorithmO(log n)
Insertion of an element in to Unordered Array O(1)
Deletion of an element from Unordered ArrayO(n)
Insertion of an element in to Ordered Array O(n)
Deletion of an element from Ordered ArrayO(n)
Recommended Posts 