C # Data Structure-Find

Source: Internet
Author: User

One: Find 1.1Basic concepts and terminology

find (Search) is to determine in the data structure whether there is a key code equal to the given key code of the recorded process. key code has the main key code and sub-key code. Main key code can uniquely distinguish between different records, the secondary key code is usually Can only distinguish between the different record. The main key code search is the most frequent, but also the most important find static find (DYNAMIC  search) two kinds. Static lookup is Refers to the data structure only to find if there is a key code equal to the given key code record without changing the node structure, Dynamic lookup refers to inserting records that do not exist in the data structure during the lookup process, or from the data structure

< Span class= "FONTSTYLE0" > The most important criterion for measuring the lookup algorithm is the average lookup length (average Search length < Span class= "FONTSTYLE0" > ASL

                                    

  where Pi is the probability of finding the occurrence of a record, Ci is the number of key code comparisons that need to be made to find the corresponding record.

1.2 Static lookup table

because static lookups do not require the insertion or deletion of records in a static lookup table, the number of static lookup tables  A structure is a linear structure that can be a static lookup table for sequential storage or a statically lookup table for chained storage. The following usessequential tables are stored as static lookup tables in sequential order, and single-linked lists are stored as chainedStatic lookup table.

1.2.1Sequential Lookup

Sequential Lookup (sequnce search) is also called linear search (Linear search), the basic idea is: from the static    < Span class= "FONTSTYLE0" > If there is a record in the table to find, the lookup succeeds and gives the position of the record in the table; otherwise, the lookup fails, giving the failure information.

< Span class= "Fontstyle1" >     time complexity, that is o (n)

< Span class= "FONTSTYLE0" >     /span>

< Span class= "FONTSTYLE0" >     1.2.2 Search for ordered tables

binary find also called binary search, the basic idea is: in an ordered table, take the to find Span class= "FONTSTYLE0" > The key code of the record is less than the key code of the intermediate record, then the left half of the intermediate record

Span class= "FONTSTYLE0" > area to continue searching. The lookup process is repeated until the lookup succeeds, or there is no record in the ordered table to find.
/span>

/span>

  

< Span class= "FONTSTYLE0" >  






  

C # Data Structure-Find

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.