Simple Search🦌

Tehleel Mir
Feb 28, 2022
Photo by Kayla Farmer on Unsplash

simple search is a search algorithm used to look for an element in an array or a list.

Time Complexity
The time complexity of a simple search is O(n) i.e. Linear time

Explanation
In order to look for an x element in the simple search we have to check every element in the list, e.g. if there are 10 elements in the list we have to check each element and see if it matches the element which we are looking for.

And in the worst case, that element can be at the end of the list, so for n elements (where n is the number of elements in a list), we have to do n operation on a list. So that’s what the O(n) stands for.

code

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response