[Solved] The complexity of linear search algorithm is:  (2024)

Concept:

Linear search : Search is an operation in which a given list is searched for a particular value. A list can be searched sequentially wherein the search for the data item starts from the beginning and continues till the end of the list. This search method is known as linear search.

Explanation:

Algorithm:

1) Take first element and compare this with the element we want to search.

2) If matches, then go to step 5.

3) Else, consider next element and go to step 1.

4) If element not found, then go to step 6.

5) element found, then return the location of element.

6) Exit

Linear search makes n/2 comparisons on an average where n is the number of elements. At the most, linear search takes n comparisons.

So, overall complexity in the worst case of linear search algorithm is O(n).

[Solved] The complexity of linear search algorithm is:  (2024)
Top Articles
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6618

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.