Data structure: string

Source: Internet
Author: User

First, the basic concept of a string

1. Definition of a string

    • S= "A1a2...an"

2. Basic operation of the string

Second, sequential storage structure of strings

1. Non-condensed storage of strings

Only one character is stored in a storage unit, and an element in the order table occupies a single storage unit. The concrete form is shown in Figure 1, set the string s= "How does You do".

2. String of condensed storage

Depending on the length of each machine word, as many characters as possible are stored in one word. If a word can store 4 characters, the condensed storage concrete form.

3. Byte storage of strings

Chain-type storage structure of three series
1 ///name:string2 ///Author:ja3 ///date:2015-3-94 5 6 7 ///block chain storage representation of a string8 #defineCHUNKSIZE 80//Block Size9typedefstructchunk{Ten     CharCh[chunksize]; One     structChunk *Next; A }chunk; -typedefstruct{ -Chunk *head, *tail;//head and tail pointers for strings the     intCurlen;//the current length of the string - }lstring; -  - ///Pattern Matching + intIndex (sstring s,sstring T, sstring pos) { -i = pos; j =1; +      while(I <= s[0] && J <= t[0]){ A         if(S[i] = = T[j]) {++i, ++j;}//continue to compare subsequent characters at         Else{i = i-j +2; j=1}//The pointer backs back to start matching -     } -     if(J > t[0])returni-t[0]; -     Else return 0; -}//Index
View CodeApplication of string: pattern matching

1. Traditional pattern matching

2.KMP algorithm

3/9/2015 2:48:24 PM

Data structure: 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.