Data structure notes 4 strings

Data structure notes 4 strings

Preface

Data structure notes 3 stacks and queues

Write a string of notes.

Mental framework

Four, string

exercise

Multiple choice

\1. Which of the following statements about strings is incorrect? ()

A. A string is a finite sequence of characters B. An empty string is a string composed of spaces

C. Pattern matching is an important operation of string

D. Strings can be stored sequentially or chained

\2. There are two strings p and q, where q is a substring of p, and the algorithm for finding the position where q first appears in p is called ()

A. Find substring B. Join C. Match D. Find string length

\3. The known string S='aaab', its Next array value is ()

A.0123 B.1123 C.1231 D.1211 。

\4. The next array of the string'ababaaababaa' is ().

A. 012345678999 B 012121111212

C. 011234223456 D. 0123012322345

5. The length of the string refers to ().

A. The number of different letters contained in the string B. The number of characters in the string

C. The number of different characters contained in the string D. The number of non-space characters in the string

6. The nextval of the string'ababaabab' is ().

A. (0,1,0,1,0,4,1,0,1) B. (0,1,0,1,0,2,1,0,1)

​ C. (0,1,0,1,0,0,0,1,1) D. (0,1,0,1,0,1,0,1,1)

1.B 2.C 3.A 4.C 5.B 6.A

True or False

() String is a linear table with special data objects and operations.

() The characteristic of the KMP algorithm is that the pointer indicating the main string will not become smaller during pattern matching.

() Suppose the length of the pattern string is m and the length of the target string is n. When n≈m and the pattern that matches only once is processed, the time cost of the naive matching (ie substring positioning function) algorithm may be even greater save.

\1. √ 2.√ 3. √

Short answer

Find the next[] value and nextval[] value of the following string

to sum up

The concept and pattern matching are often tested here.

Update address: GitHub

For more content, please pay attention: CSDN , GitHub , Nuggets

Guess you like

Origin blog.csdn.net/weixin_42875245/article/details/109176222