answersLogoWhite

0


Best Answer

Binary search functions by taking a sorted linear list of items, then starting at the middle of the list testing "is it equal?", "is it less?" and "is it more?"

If it is equal, then you've found your item.

It it's less than what you're looking for, then you should skip to half way between the end of the list and where you currently are positioned and try again there.

If it it's more, skip to half way to the start of the list.

As you progress, you'll narrow in on your target.

The middle item is the item located between the two points of searching. To start it's the first and last item in the list. Following, it's the midpoint between the current item and the previous item checked.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the middle item in binary search algorithm?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What search algorithm locates an item in an array by repeatedly dividing the array in half?

half means 1/2 from the whole (previous), which means 2 of 1/2, and 2 derived into binary. Ha, Binary Search is the term.


Prove by mathematical induction that the complexity of binary search algorithm is log n?

The complexity of the binary search algorithm is log(n)...If you have n items to search, you iteratively pick the middle item and compare it to the search term. Based on that comparision, you then halve the search space and try again. The number of times that you can halve the search space is the same as log2n. This is why we say that binary search is complexity log(n).We drop the base 2, on the assumption that all methods will have a similar base, and we are really just comparing on the same basis, i.e. apples against apples, so to speak.


What is the difference between linear search and binary search?

A linear search looks for an item in a list by iterating through it sequentially. Meaning that it looks at the first item, then the second item, then the third item, then the fourth and etc... Because it is possible that the item you are looking for is the very last item in the list, a linear search runs in O(n) time. For a *randomly* ordered list, the search will run on average in n/2 time. A binary search is a much more efficient algorithm which can only be used on a SORTED list. A binary search is conceptually equivalent to treating the list as a binary search tree. Because the depth of a balanced binary search tree is log n, a binary search algorithm runs in O(log n) time. Instead of starting at the beginning of the list, a binary search starts in the middle of the sorted list. If the item it is looking for is less than the item in the middle of the list, then you look in the middle of the half of the list which is less than the middle item. If the item it is looking for is greater than the middle item, then it looks in the middle of the half of the list which is greater than the middle item. This process repeats until you either find what you are looking for, or the size of the sublist that you are looking in is zero.


How you can improve search efficiency of sequential search for a sorted file?

When sequentially searching n items, the best-case is O(1) and the worst-case is O(n). But when the items are sorted, binary search will improve efficiency. The best case is still O(1), but worst case drops to O(log n) where log n is the binary logarithm of n. Binary search starts with the middle element of the set. If the set is empty, the item we're looking for does not exist but if the middle element is the item we are looking for then we are done. If not, a simple comparison will tell us in which half of the set to discard (including the middle element). We repeat the process with the remaining half. If there are no elements remaining, the item does not exist.


How you can improve search efficiency of sequential search for a sorted file. Discuss limitations in such?

When sequentially searching n items, the best-case is O(1) and the worst-case is O(n). But when the items are sorted, binary search will improve efficiency. The best case is still O(1), but worst case drops to O(log n) where log n is the binary logarithm of n. Binary search starts with the middle element of the set. If the set is empty, the item we're looking for does not exist but if the middle element is the item we are looking for then we are done. If not, a simple comparison will tell us in which half of the set to discard (including the middle element). We repeat the process with the remaining half. If there are no elements remaining, the item does not exist.

Related questions

What is the worst case and best case for binary search?

The best case for a binary search is finding the target item on the first look into the data structure, so O(1). The worst case for a binary search is searching for an item which is not in the data. In this case, each time the algorithm did not find the target, it would eliminate half the list to search through, so O(log n).


What search algorithm locates an item in an array by repeatedly dividing the array in half?

half means 1/2 from the whole (previous), which means 2 of 1/2, and 2 derived into binary. Ha, Binary Search is the term.


Prove by mathematical induction that the complexity of binary search algorithm is log n?

The complexity of the binary search algorithm is log(n)...If you have n items to search, you iteratively pick the middle item and compare it to the search term. Based on that comparision, you then halve the search space and try again. The number of times that you can halve the search space is the same as log2n. This is why we say that binary search is complexity log(n).We drop the base 2, on the assumption that all methods will have a similar base, and we are really just comparing on the same basis, i.e. apples against apples, so to speak.


What is the difference between linear search and binary search?

A linear search looks for an item in a list by iterating through it sequentially. Meaning that it looks at the first item, then the second item, then the third item, then the fourth and etc... Because it is possible that the item you are looking for is the very last item in the list, a linear search runs in O(n) time. For a *randomly* ordered list, the search will run on average in n/2 time. A binary search is a much more efficient algorithm which can only be used on a SORTED list. A binary search is conceptually equivalent to treating the list as a binary search tree. Because the depth of a balanced binary search tree is log n, a binary search algorithm runs in O(log n) time. Instead of starting at the beginning of the list, a binary search starts in the middle of the sorted list. If the item it is looking for is less than the item in the middle of the list, then you look in the middle of the half of the list which is less than the middle item. If the item it is looking for is greater than the middle item, then it looks in the middle of the half of the list which is greater than the middle item. This process repeats until you either find what you are looking for, or the size of the sublist that you are looking in is zero.


When is it not recommended to perform the operation of binary search?

In computer science, a binary search or half-interval search algorithm finds the position of a specified value (the input "key") in an array sorted[1][2] into order on the values of the key. At each stage, the algorithm compares the sought key value with the key value of the middle element of the array. If the keys match, then a matching element has been found so its index is returned. Otherwise, if the sought key is less than the middle element's key, then the algorithm repeats its action on the subarray to the left of the middle element or, if the input key is greater, on the subarray to the right. If the array span to be searched is reduced to zero, then the key cannot be found in the array and a special "Not found" indication is returned.A binary search halves the number of items to check with each iteration, so locating the an item (or determining its absence) takes logarithmic time. A binary search is a dichotomic divide and conquer search algorithm.Next AnswerA binary search method requires that the list of items being search should be sorted in ascending (or descending) order. If the search list is not sorted, the binary search method will not work and other search methods will be needed.


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


How you can improve search efficiency of sequential search for a sorted file?

When sequentially searching n items, the best-case is O(1) and the worst-case is O(n). But when the items are sorted, binary search will improve efficiency. The best case is still O(1), but worst case drops to O(log n) where log n is the binary logarithm of n. Binary search starts with the middle element of the set. If the set is empty, the item we're looking for does not exist but if the middle element is the item we are looking for then we are done. If not, a simple comparison will tell us in which half of the set to discard (including the middle element). We repeat the process with the remaining half. If there are no elements remaining, the item does not exist.


How you can improve search efficiency of sequential search for a sorted file. Discuss limitations in such.?

When sequentially searching n items, the best-case is O(1) and the worst-case is O(n). But when the items are sorted, binary search will improve efficiency. The best case is still O(1), but worst case drops to O(log n) where log n is the binary logarithm of n. Binary search starts with the middle element of the set. If the set is empty, the item we're looking for does not exist but if the middle element is the item we are looking for then we are done. If not, a simple comparison will tell us in which half of the set to discard (including the middle element). We repeat the process with the remaining half. If there are no elements remaining, the item does not exist.


How you can improve search efficiency of sequential search for a sorted file. Discuss limitations in such?

When sequentially searching n items, the best-case is O(1) and the worst-case is O(n). But when the items are sorted, binary search will improve efficiency. The best case is still O(1), but worst case drops to O(log n) where log n is the binary logarithm of n. Binary search starts with the middle element of the set. If the set is empty, the item we're looking for does not exist but if the middle element is the item we are looking for then we are done. If not, a simple comparison will tell us in which half of the set to discard (including the middle element). We repeat the process with the remaining half. If there are no elements remaining, the item does not exist.


What are the Advantages of binary search on linear search in c?

(i) Binary search can interact poorly with the memory hierarchy (i.e. caching), because of its random-access nature. For in-memory searching, if the interval to be searching is small, a linear search may have superior performance simply because it exhibits better locality of reference. (ii) Binary search algorithm employs recursive approach and this approach requires more stack space. (iii) Programming binary search algorithm is very difficult and error prone (Kruse, 1999).


Is it true In a binary search if the search fails to find the item on the first attempt then there are 999 elements left to search in an array of 1000 elements?

False. In a binary search, if the search fails on the first trial of an array of 1000 elements, then there are only nine more elements left to search.


Why binary search is used for the large values of arrays?

Binary search is used for large arrays because it is the fastest search, on the order of O-Log2-N complexity, which means that the maximum number of compare operations to find a specific item is Log2N, where N is the number of elements.