In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the storage mode and element arrangement requirements of the table suitable for binary search, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.
The storage mode and element arrangement requirements of the table suitable for half-and-half search are as follows: sequential storage and orderly elements. Binary search is an efficient search method, which requires that the linear table must adopt a sequential storage structure, and the elements in the table are arranged in order according to keywords.
Binary search, also known as half search (Binary Search), is a more efficient search method. However, half-and-half lookup requires that the linear table must have a sequential storage structure, and the elements in the table are arranged in order by keyword.
First of all, assuming that the elements in the table are arranged in ascending order, compare the keywords recorded in the middle of the table with the search keywords, and if the two are equal, the search is successful; otherwise, the table is divided into the first and the last two sub-tables by using the intermediate location records. if the keyword of the intermediate location record is greater than the search keyword, then further look for the previous sub-table, otherwise further look for the latter sub-table. Repeat the above process until a record that meets the criteria is found, making the search successful, or until the child table does not exist, where the lookup is not successful.
Algorithm requirement
1. The sequential storage structure must be adopted.
2. It must be arranged in order according to the size of keywords.
Number of comparison
Calculation formula:
When the sequence table has n keywords:
When the lookup fails, compare the keywords at least a times; when the lookup is successful, the maximum number of keyword comparisons is b.
Note: a _ r _ b _ r _ n are positive integers.
Description
Half-and-half search method, also known as binary search method, makes full use of the order relationship between elements, adopts divide-and-conquer strategy, and can complete the search task with O (log n) in the worst case. Its basic idea is: (it is assumed that the array elements are arranged in ascending order) divide n elements into two halves with roughly the same number, compare a [nprime 2] with the x you want to find, if x find x, and the algorithm terminates; if xa [nprime 2], then we just continue to search for x in the right half of the array a.
Thank you for reading this article carefully. I hope the article "the storage mode and element arrangement requirements of the table suitable for binary search" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.