Today, let us touch base on some fundamental concepts like search algorithms.
In simple terms, **searching **is a process of looking up a particular data record in the database or in the collection of items. A search typically answers as true or false whether the particular data in which we are referring is found or not and perform the next action accordingly.
Commonly used algorithms for search are:
Let us understand them in detail with some example
Linear Search Algorithm is the simplest and easiest form of the search algorithm. In this algorithm, a sequential search is made over all the items one by one to search for the targeted item. Each item is checked in sequence until the match is found. If the match is found, the searched item is returned otherwise the search continues till the end.
To make it easy to understand, let us see understand linear search using a flow diagram
Linear Search — Data Flow
In _Binary search algorithm, _begins with an interval covering the whole array and diving it in half. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.
To make it easy to understand, let us see understand binary search using flow diagram and example as below.
Binary Search — Data Flow
#sorting-algorithms #algorithms #data-structures #search-and-sort #searching-algorithm