top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Big-O notation? Please explain with some examples?

+3 votes
508 views
What is Big-O notation? Please explain with some examples?
posted Jun 9, 2015 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The Big-O notation describes the performance of an algorithm in terms of number of elements in a data structure. Since Collection classes are actually data structures, we usually tend to use Big-O notation to chose the collection implementation to use based on time, memory and performance.

Example 1: ArrayList get(index i) is a constant-time operation and doesn’t depend on the number of elements in the list. So it’s performance in Big-O notation is O(1).
Example 2: A linear search on array or list performance is O(n) because we need to search through entire list of elements to find the element.

answer Aug 30, 2017 by Sandeep Jain
...