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
2.1k views
in Computer by (69.4k points)

Write an algorithm to search for given ITEM in a given array X[n] using linear search technique. If the ITEM is found, move it at the top of the array. If the ITEM is not found, insert it at the end of the array. 

1 Answer

+1 vote
by (61.3k points)
selected by
 
Best answer

Students I gave you solution of 2 part of the question First part Linear Search Technique Algorithm

1. LB=0

2. Repeat steps 3 and 4 until LB>UB //UB means Upper Bound(length of array)

3. If ARR[LB]==ITEM then

{

pos=LB break 

}

4. LB=LB+1

5. if LB>UB then

print "Value Not Found"

else

//Second part swapping of searched item at top of the array

temp=ARR[pos]

ARR[pos]=ARR[0] 

ARR[0]=temp

}

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

...