Linear Searching
In linear search we access each element of an array one by one sequentially and see whether it is desired element or not. A search will be unsuccessful if all the elements are accessed and the desired is not found. In the worst case the number of average case we may have to scan half of the size of the array (n/2). Therefore linear search can be defined as the technique which traverses the array sequentially to locate the given item. The program given below demonstrates the searching of an element of the array using search.
Efficiency of sequential searching
The time taken or the number of comparisons made in searching a record in a search table determines the efficiency of the technique.
If the desired record is present in the first position of the search table then only one comparison is made. If the desired record is the last one, then n comparison have to be made. If the record is present somewhere in the search table on an average the number of comparison will be (n+1)/2. The worst case efficiency of this technique is O (n) stands for the order of execution.
Algorithm
Here a is a linear array with n elements and item is a given item of information. This algorithm finds the location loc of item in a or sets loc =0 if the search is unsuccessful.
Data Structure & Algorithms Assignment Help, Live Experts
Struggling with data structure problems? Data structure subject is quite tough to learn? Need quick assistance in data structure questions? ExpertsMind.com is right place for you where your search ends, We at ExpertsMind offer online data structure assignment help, data structure homework help and data structure and algorithms question's answers by best online support by qualified tutors.
ExpertsMind.com - Linear Searching Assignment Help, Linear Searching Homework Help, Linear Searching Assignment Tutors, Linear Searching Solutions, Linear Searching Answers, Searching and Hashing Assignment Tutors