Searching
Searching is to find or locate an item or data in a list or an array. There are two methods of searching:
i) Sequential search and ii) Binary Search
i) Sequential Search : In a sequential search the item or data to be searched is first compared with the first element of the array(list). If a match is found then the search is over, otherwise the data is compared with the second element. If the match is found, then the search is over or else the data is compared with the next element, i.e. the third element. This process is continued till, either the match is found or till the last element is compared. In case match is not found till the last element has been compared, then it is concluded that the data being searched is not in the list.
Algorithm for sequential search is given below :
Alogorithm :
Let ‘A’ be an array containing ‘n’ elements.
Step 1 : Start
Step 2 : read the data to be searched (data)
Step 3 : set i to 0
Step 4 : repeat step 5 through step 8 while(i
Description
Whwt Is searching ? Methods of searching:- Sequential search & Binary search. About sequential search
Presentation Transcript
Your Facebook Friends on WizIQ