answersLogoWhite

0


Best Answer

There is no such thing as an insertion search. There is only insertion sort, which is a method of sorting an unsorted list. Sequential search (or linear search) is only used with unsorted lists. If the list is sorted, a logarithmic search is quicker, by starting from the middle. If the items is not here, it must be in the lower half or the upper half, thus one half of the list can be discarded. You then repeat by starting in the middle of the remaining half. Thus for a list of 15 items, you end up with a list of 7, then 3, then 1, then 0. Thus it takes 5 comparisons to determine that an item does not exist. With linear search it would take 15 comparisons to determine that an item does not exist. Thus logarithmic search is quicker, but only works with sorted lists.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

6y ago

Binary search is faster than sequential search on average.

Sequential search is only necessary with non-ordered arrays and has a worst-case time-complexity of O(n) for a set of n elements whereas searching an ordered array using binary search algorithm has a worst-case of O(log n).

In C Programming, we can implement binary search upon an ordered array of int as follows:

size_t binary_search (int* array, size_t size, int value) {

size_t lo, mid, hi; // variables to keep track of subarray bounds and middle index

if (array && size) { // ensure array arguments are valid

lo = 0;

hi = size; // note: half-open range [lo:hi)

while (hi>lo) {

mid = lo + ((hi - lo) / 2); // (re)calculate middle index of subarray [lo:hi)

if (array[mid]==value) {

return mid; // value found at array[mid]

}

// determine which half of the remaining subarray to search...

if (array[mid]<val) {

lo = mid+1; // search the upper half

} else {

hi = mid; // search the lower half

}

}

}

return size; // value not found or invalid array arguments

}

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

A binary search keeps splitting an array in half until the element is found or not found. With a binary search, you eliminate 1/2 the possible entries with each iteration. The number of operations for this logarithmic to the number of elements or in big O notation as O(log N) where N is the number of elements.

A sequential search at best finds the element on the first element and at worst the last nth element so on average the number of elements to be searched is N/2 or in big O notation simply O(N).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Which one is faster A binary search of an ordered set of elements in an array or a sequential search of the elements?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

A binary search of an orderd set of elements in an array or a sequential search of the elements.Which one is faster?

A binary search is much faster.


Advantages of binary search over sequencial search?

Linear search takes linear time with a worst case of O(n) for n items, and an average of O(n/2). Binary search takes logarithmic time, with a worst and average case of O(n log n). Binary search is therefore faster on average.


Which is faster binary tree or binary search tree?

A tree doesn't do anything so it has no speed...


What are the advantages and disadvantages of binary search algorithms?

the major limitation of binary search is that there is a need of sorted array to perform binary search operation. if array is not sorted the output is either not correct or may be after a long number of steps and according to data structure the output should come in minimum number of steps.


How do you overcome drawbacks of linked list?

Overcoming the "drawbacks" of a linked list requires knowing what drawback is at stack. If you need to iterate backwards as well as forwards, then you could create a doubly linked list. If you need to search for elements quickly, then you could implement a binary tree. If you have a static size, then you could implement an array. It's all a matter of tradeoff, and of what your particular issue is... Its badsector... According to my self disadvantage of link list that searching in link list is sequential if you compare it with arrays its very slow. Because in link list we have to search every node for that. if any one uses binary tree that is in some cases more faster than arrays.

Related questions

A binary search of an orderd set of elements in an array or a sequential search of the elements.Which one is faster?

A binary search is much faster.


How does sequential search work?

In computer science, linear search or sequential search is a method for finding a particular value in a list, that consists of checking every one of its elements, one at a time and in sequence, until the desired one is found.[1]Linear search is the simplest search algorithm; it is a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list; and so is its expected cost, if all list elements are equally likely to be searched for. Therefore, if the list has more than a few elements, other methods (such as binary search or hashing) will be faster, but they also impose additional requirements. (Source: Wikipedia)


Advantages of binary search over sequencial search?

Linear search takes linear time with a worst case of O(n) for n items, and an average of O(n/2). Binary search takes logarithmic time, with a worst and average case of O(n log n). Binary search is therefore faster on average.


Which is faster binary tree or binary search tree?

A tree doesn't do anything so it has no speed...


What are the advantages and disadvantages of binary search algorithms?

the major limitation of binary search is that there is a need of sorted array to perform binary search operation. if array is not sorted the output is either not correct or may be after a long number of steps and according to data structure the output should come in minimum number of steps.


Does a drive perform better if it reads data randomly or sepuentially?

Definitely faster if it's sequential. That's why you should periodically defrag.


What is SEFI?

Sequential Electronic Fuel Injection. In a sequential fuel injection system, the injectors open one at a time, in conjunction with the opening of each cylinder. Some other injection systems may open all injectors simultaneously. The sequential option is advantageous because it allows for faster response when the driver makes a rapid change.


How do you overcome drawbacks of linked list?

Overcoming the "drawbacks" of a linked list requires knowing what drawback is at stack. If you need to iterate backwards as well as forwards, then you could create a doubly linked list. If you need to search for elements quickly, then you could implement a binary tree. If you have a static size, then you could implement an array. It's all a matter of tradeoff, and of what your particular issue is... Its badsector... According to my self disadvantage of link list that searching in link list is sequential if you compare it with arrays its very slow. Because in link list we have to search every node for that. if any one uses binary tree that is in some cases more faster than arrays.


What are molecules that are joined in an ordered structure?

When molecules are linked in organized positions has solid results. When heat is absorbed by a solid the molecules vibrate faster and faster.


The faster-moving star in a binary is?

A binary star is two stars which orbit their mutual center of mass. The more massive star will move more slowly, while the lighter star will move more quickly.


Why 'C' is sequential language?

C is sequential id est procedural - it has no abstraction layer to facilitate the object oriented programming paradigm... However this can be coded in if required and is - in the case of objective C. Procedural or sequential programming basically means that the program in question is broken down into a sequence of steps or instructions and these are followed in order to make the program function. This is done in a linear fashion.Due to being sequential and procedural C does not have the "Bloat" of the C++ object oriented programming model. Therefore the programs are smaller and generally faster.


Are elements added to oceans at a faster rate than they are removed?

No false