answersLogoWhite

0

The linear search problem relates to searching an un-ordered sequence. Because the data is no ordered, we must start at one end of the sequence and inspect each element in turn tunil we find the value we are looking for. If we reach the one-past-the-end of the sequence, the value does not exist. From this we can see that for a set of n elements, the worst case (the element does not exist) is O(n) time while the best case is O(1) time (the element we seek is the first element). Given that there is a 50/50 chance the element we seek will be closer to the start of the sequence than the end, the average seek time is O(n/2).

When a set is ordered we can reduce search times by starting in the middle of the set. In this way, if the element is not found we can eliminate half of the set because we know which half contains the value (if it exists). We repeat the process until we find the value in the middle of the remaining set or the remaining set is empty. The end result is that search times are reduced to a worst case of O(log n), the binary logarithm of n.

User Avatar

Wiki User

8y ago

What else can I help you with?

Related Questions

What is search algorithm?

The linear search algorithm is a special case of the brute force search.


What is linear searching?

The linear search algorithm is a special case of the brute force search.


How does the jump search algorithm improve the efficiency of searching for a specific element in a sorted array?

The jump search algorithm improves search efficiency by jumping ahead in fixed steps to quickly narrow down the search range, making it faster than linear search. It then performs a linear search within the smaller range to find the specific element in a sorted array.


How can you convert a simple algorithm to recursive algorithm?

Linear search(a,item) n=length(a) for i=1 to n do if(a[i]==item) then return i end for return -1


What is the best search algorithm to use for an unsorted array?

The best search algorithm to use for an unsorted array is linear search. It involves checking each element in the array one by one until the desired element is found. This algorithm has a time complexity of O(n), where n is the number of elements in the array.


The time complexity of the sequential search algorithm is?

O(N) where N is the number of elements in the array you are searching.So it has linear complexity.


What is the best search algorithm to use for a sorted array?

The best search algorithm to use for a sorted array is the binary search algorithm.


What algorithm uses a loop to step through each element of an array starting with the first element searching for a value?

What you're describing is called a sequential search or linear search.


Which search algorithm requires that the arrays contents be sorted?

Binary Search Algorithm


Is the complexity of searching in a database logarithmic?

No, the complexity of searching in a database is typically not logarithmic. It is often linear or even higher, depending on the specific search algorithm and the size of the database.


Which type of search algorithm checks every element on the list in sequence until a matching data is found?

It's called "Linear Search". If the list is sorted, then it is possible to perform more advanced searches like binary search. If the list isn't sorted, then you can either sort the list first and then binary search or simply use a linear search. Linear search is typically a brute force solution when the data isn't "planned" or if the data is stored in a linked list where random access of the values in the list is slow.


Explain linear search with an example?

Sequential search of an object with in an array of objects is called as linear search.