"Big Talk Data Structure"---fifth chapter string

Source: Internet
Author: User

Strings are a finite sequence of 0 or more characters, the Nether teaches strings. It is generally remembered as a = "aaaaaa"; the number of characters in a string n is called the length of a string. A string of 0 characters is called an empty string.

A space string is a string that contains only spaces. The space string has a length of content. A subsequence of any number of consecutive characters in a string is called a substring of that string. The string containing the substring is called the main string. The position of the substring in the live string is the ordinal number of the first character of the substring in the main string. Strings can be compared in size. The comparison of strings is by the encoding of strings between the characters. This is the ASCII code. The locating operation of a substring is often called a pattern match of a string. KMP Pattern matching algorithm. Simple to understand. Compare if there is a B string in a string. Match to find a string equal to the string B character. If unsuccessful at the end of this match, the distance between this character in a string and the middle of the matching failure character does not need to be traversed. When you have the same character in a string, you need to take into account an array of next. The array that stores the subscript difference value for the same character. ABCABX when n = 1 o'clock, next[1] = 0;n = 2 o'clock, next[2] = 1;n = 3 o'clock, next[3] = 1;n = 4 o'clock, next[4] = 1;n = 5 o'clock, store the first 4 characters in a string, prefix character equals suffix character, prefix character and suffix The middle of the character contains two characters, so next[5] = 2; the previous difference may also be one of the same small string with the distance of the small string n = 6 o'clock, because the prefix character is equal to the preceding character of the prefix character and the suffix character and the suffix character, so the difference is +1,next[6] = 3; This algorithm needs to open a single chapter detailed understanding.

"Big Talk Data Structure"---fifth chapter string

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.