数据结构与算法课后题整理(三)

第三章

1.(2分)串是任意有限个( ) 。

A.符号构成的集合
B.符号构成的序列
C.字符构成的集合
D.字符构成的序列

2.(2分)串是一种特殊的线性表,其特殊性体现在( )。

A.可以顺序存储
B.数据元素是一个字符
C.可以链式存储
D.数据元素可以是多个字符

3.(2分)两个串相等必有串长度相等且( )。

A.串的各位置字符任意
B.串中各位置字符均对应相等
C.两个串含有相同的字符
D.两个串所含字符任意

4.(2分)设有数组定义:char array[] = “China”;则数组array所占的存储空间( )。

A.4个字节
B.6个字节
C.5个字节
D.7个字节

5.(2分)设有数组定义:char array[10] = “China”;则数组array所占的存储空间为( )。

A.4个字节
B.5个字节
C.6个字节
D.10个字节

6.(2分)数组在存储字符串常量时通常需要在其末尾带一个结束标记( )来表示串的结束。

A.’\0’
B.’#’
C.‘0’
D.’#’

7.已知字符串S为"abaabaabacacaabaabcc", 模式串t为"abaabc"。采用KMP算法进行匹配,笫一次出现匹配失败时,i=j=5, 则下次开始匹配时,i和j的值分别是( ) 。

A.i=1,j=0
B.i=5,j=0
C.i=5,j=2
D.i=6,j=2

8.已知串S=“abababc”,其特征向量为( ) 。

A.0012340
B.0112340
C.0012341
D.0123400

9.KMP算法的特点是在模式匹配时指示主串的指针( )。

A.不会变大
B.不会变小
C.都有可能
D.无法判断

10.(2分)Which of the following is the incorrect way to assign a string value?

A.char *str; str = “string”
B.char str[7]={‘s’,‘t’,‘r’,‘i’,‘n’,‘g’}
C.char str1[10]; str1 = "string"
D.char str1[]=“string”, str2[] = “1234567”

11.(2分)Assume that strings s=“abcd”,s1=“123”, then executing s2=InsStr(s,2,s1),s2=( )。

A.“123abcd”
B."a123bcd"
C.“ab123cd”
D.“abc123d”

12.(2分)Assume that string s=“abcd”, then executing s2=DelStr(s,2,2),s2=

A.“abcd”
B.“abc”
C."ad"
D.“a”

13.(2分)If the length of the main string is n and the length of the substring is m, then the time complexity of the Naive string matching algorithm is( ) 。

A.O(m)
B.O(n)
C.O(m*n)
D.O(m+n)

14.(2分)If the length of the main string is n and the length of the substring is m, then the time complexity of the KMP algorithm is( )。

A.O(m+n)
B.O(m)
C.O(n)
D.O(m*n)

15.(2分)设有两个串S1和S2, 求S2在S1中首次出现的位置的运算称作( )。

A.求子串
B.判断是否相等
C.模式匹配
D.连接

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值