Linear Search-Data Structure

Sandhya Reyya
2 min readJan 28, 2022

--

Searching is always finding something or someone in our real life. It can be a file, document, or opportunity. In reality, people have their own logic or formulae to search. But when we come to technical platforms, logics should be trained to our computer.

The basic searching technique in data structures is Linear Search. The term explains the logic of the searching, Line format, or one-by-one. The logic goes in such a way, searching starts from starting point to the ending point without skipping anything.

The data points are not compulsion to sort while searching. If we have 7 elements, the searching starts from the first element. If the element is not matched with the searching element, it moves a step ahead repeats the same. If the element is matched, it stops the process and informs the element is existing in the data. If there are no elements for further search, it indicates, the element is not existing.

Let us see the algorithm for linear search:

Step 1: Start

Step 2: Get all the data where you wanted to search in

Step 3: Input the search element

Step 4: i=start index

Step 5: if the element at i is equal to the search element go to step 9

Step 6: i=i+1

Step 7: if i is lesser than the length of data structure go to step 5

Step 8: else goto step 10

Step 9: Output “Element is existing” go to step 11

Step 10: Output “ Element is not existing” go to step 11

Step 11: Stop

Program in C language:

Program in java language:

This is all about linear search.

Thanking You.

--

--

Sandhya Reyya
Sandhya Reyya

No responses yet