Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
76 views
in Computer by (51.9k points)
closed by

Explain Linear Search.

1 Answer

0 votes
by (49.5k points)
selected by
 
Best answer

Linear search is the most fundamental and the simplest search method. It is an exhaustive searching technique where every element of a given list is compared with the item to be searched (usually referred to as ‘key’). So, each element in the list is compared one by one with the key. This process continues until an element matching the key is found and we declare that the search is successful. If no element matches the key and we have traversed the entire list, we declare the search is unsuccessful i.e., the key is not present in the list. This item by item comparison is done in the order, in which the elements are present in the list, beginning at the first element of the list and moving towards the last. Thus, it is also called sequential search or serial search. This technique is useful for collection of items that are small in size and are unordered. 

Given a list numList of n elements and key value K, Algorithm uses a linear search algorithm to find the position of the key K in numList.

Algorithm : Linear Search

LinearSearch(numList, key, n) 

Step 1: SET index = 0 

Step 2: WHILE index < n, REPEAT 

Step 3 Step 3: IF numlist[index]= key THEN 

PRINT “Element found at position”, index+1 

STOP 

ELSE index = 

index+1 

Step 4: PRINT “Search unsuccessful”

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...