Differences Between Linear Search and Binary Search

What are the differences between Linear Search and Binary Search?

Search is a function that is required and mostly used. We all need to search at some point. Two main searching methods are linear search and binary search.
Let’s see the differences between them.

Linear search

Binary search

1. It searches from the beginning to end. 1. It searches from the middle.
2. It takes more time to find if the number is at the end. 2. It takes more time even the searched item is at the beginning.
3. The items may be sorted. 3. The items must be sorted.
4. It is inefficient with large data. 4. It is more efficient than linear search.
5. Its big-Oh notation is O(n). 5. Its big-Oh notation is O(log(n))

Leave a Reply

Your email address will not be published. Required fields are marked *