Fold Half Find and Sequential Find Differences?

Updated on technology 2024-02-16
7 answers
  1. Anonymous users2024-02-06

    <> sequential search, also known as linear search, is a fool-proof search from beginning to end, and half of the search.

    It is in the ordered table, half to find, for example, an ascending table, the first element is a, the middle element is b, the last element is c, at the beginning, the element x that needs to be found is compared with the element b in the middle position, if x > b, then then find the element between b-c, otherwise find the element between a-b, and then the same ,,, I typed word by word, give points to point encouragement...

  2. Anonymous users2024-02-05

    Sequential search is a simple search from beginning to end, and there is no requirement for data, while the data required to be found in half is arranged in order, and then find the middle number, if the middle number is large, then the middle number is the last number to find their middle number. Otherwise, the middle number is taken as the first number. Find their middle number.

    And so keep searching until you find that either the middle number is equal to the first or last number. It is more efficient than sequential search.

  3. Anonymous users2024-02-04

    The difference lies in the search speed, for example, if a table has 1000 items, the average half-half search needs to be found 500 times, while the maximum half-half search is only ln1000 ln2+1=10 times.

    The difference in implementation is that sequential lookups are found one by one and do not need to be sorted; The half-fold search needs to be sorted first, and then the half-fold search is divided into sizes each time.

  4. Anonymous users2024-02-03

    At least 50 times off, 60 times for a successful lookup.

    First, assuming that the elements in the table are arranged in ascending order, compare the keywords recorded in the middle of the table with the lookup keywords, if the two are equal, the lookup is successful. Otherwise, the intermediate position record is used to divide the table into two subtables, the first and last subtables, if the keyword of the intermediate location record is greater than the search keyword, the previous subtable is further searched, otherwise the next subtable is further searched.

    Repeat the above process until a record that satisfies the criteria is found, making the lookup successful, or until the child table does not exist, in which case the lookup is unsuccessful.

    The basic idea is to divide n elements into two halves with approximately the same number (assuming that the array elements are arranged in ascending order), compare a[n 2] with the x you want to find, and if x=a[n 2], then find x, and the algorithm terminates; If xa[n 2], then we just need to continue searching for x in the right half of the array a.

  5. Anonymous users2024-02-02

    At least 50 times off, 60 times for a successful lookup.

    First, 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 two sub-tables, the first and last sub-tables are used to use the middle position positive swimming record, and if the keyword of the middle position record is greater than the search keyword, the previous sub-table is further searched, otherwise the latter sub-table is further searched.

    Repeat the process until a record that satisfies the criteria is found, making the lookup successful, or until the child table does not exist, at which point the lookup is unsuccessful.

    The basic idea is to divide n elements into two halves with approximately the same number (assuming that the array elements are arranged in ascending order), compare a[n 2] with the x you want to find, and if x=a[n 2], then find x, and the algorithm terminates; If xa[n 2], then we just need to continue searching for x in the right half of the array a.

  6. Anonymous users2024-02-01

    The half-fold search method is a more efficient search method, assuming that there are five integers a0 a4 that have been arranged in order from smallest to largest, and the number to be found is x, and its basic idea is:

    Let the lower limit of the search data range be l=0 and the upper limit is h=4, find the midpoint m=(l+h) 2, compare x with the midpoint element am, if x is equal to am, that is, find it, stop the search.

    Otherwise, if x is greater than am, replace the lower limit l=m+1 and continue to search in the lower half.

    If x is less than am, the upper limit of h=m-1 is exchanged, and the search is continued in the first half, and so on until the previous process is found or l>h.

    If l>h, it means that there is no such number, the printing cannot find the information, and the program ends.

    This method keeps shrinking the search range by half, so the search efficiency is high.

  7. Anonymous users2024-01-31

    The half-fold check and the search can be described with the help of a binary tree.

    For the sake of simplifying the discussion, let's approximate the tree as a full binary tree, and let the height of the binary tree be h(h>1).

    Then, according to the nature of the binary tree, it has a maximum number of nodes n=2 h-1 next to it, then h=log2(n+1) (2 is the base). Then the number of nodes at layer j of the binary tree is: 2 (j-1).

    Assuming that the find probability of each element is equal, then, pi = 1 n (pi is the find probability of the ith node).

    Then the average lookup length is 1 n*(1*2 0+2*2 1+3*2 2+......j*2^(j-1))

    The average search length is obtained as follows: ((n+1) n ) log2(n+1)-1 (where 2 in the logarithm is the base: that is, the logarithm with 2 as the base (n+1)).

    Note: When n is large, it can be approximated as log2(n+1)-1

    The search process starts with the middle element of the array, and ends if the middle element happens to be the one to be found; If a particular element is larger or smaller than the intermediate element, it is found in the half of the array that is greater or smaller than the intermediate element.

Related questions
6 answers2024-02-16

Adult: The teacher asked us.

What do you want to be when you grow up? >>>More

11 answers2024-02-16

You don't need that cumbersome plugin, you just need to change its width="?px" height="?px"Then change it to this size.

34 answers2024-02-16

Install a celetask task manager.,Run the task manager when you want to see it.,You can see it all.,You can do it to、Turn off to check the battery level、Check the memory card capacity、Restart the phone、Clean up the memory and other operations,This is the **address:

9 answers2024-02-16

In order to help you find the right business information for you faster, please pay attention to the following points: >>>More

14 answers2024-02-16

domain name:

registrar: xiamen chinasource internet service co., ltd. >>>More