2020-11-17

2-1
假设有六列火车,按编号1,2,3,4,5,6的顺序开进一个栈式结构的站台,问下列序列中,哪个是可能的出站序列。( )
A.1,2,6,4,5,3 B.5,2,3,4,6,1 C.3,1,2,6,5,4 D.3,2,1,6,5,4
2、栈和队列具有相同的。
A.抽象数据类型B.逻辑结构C.存储结构D.运算
3、假定利用数组a[n]顺序存储一个栈,用top表示栈顶指针,用top==-1表示栈空,并已知栈未满,当元素x进栈时所执行的操作为( )。
A.a[–top]=xB.a[top–]=xC.a[++top]=x D.a[top++]=x
4、执行完下列语句段后,i的值是( )。
int f(int x){
return ((x>0)?x*f(x-1):2);
}
int i;
i=f(f(1));

A.2B.4C.8D.无限递归
5、已知程序如下:。

int S(int n)
{ return (n<=0)?0:s(n-1)+n;}
void main()
{
count<<S(1);
}
程序运行时使用栈来保存调用过程的信息,自栈底到栈顶保存的信息依次对应的是( )
A.main()→S(1)→S(0)B.S(0)→S(1)→main()C.main()→S(0)→S(1)D.S(1)→S(0)→main()
6、栈操作数据的原则是____。

A.先进先出B.后进先出C.后进后出D.不分顺序
7、Given the popping sequence of a stack as {1, 2, 3, 4, 5}. Among the following, the impossible pushing sequence is:
A.3 2 1 5 4B.5 1 2 3 4C.4 5 1 3 2D.5 4 1 2 3
8、Given the popping sequence of a stack as {a, b, c, d, e}. Among the following, the impossible pushing sequence is:

A.c b a e dB.d e a c bC.e a b c dD.e d a b c
9
If keys are pushed onto a stack in the order abcdef, then it’s impossible to obtain the output sequence ( ).
A.fedcba
B.bcafed
C.dcefba
D.cabdef
10、If keys are pushed onto a stack in the order { 1, 2, 3, 4, 5} , then in the following sequence, the legal output sequence of the stack is ()

A.
5 1 2 3 4
B.
4 5 1 3 2
C.
4 3 1 2 5
D.
3 2 1 5 4
11、Push and pop { 1, 3, 5, 6, 4, 7, 2 } sequentially into then out of a stack. Suppose that each number is pushed into a queue right after it gets out of the stack, and the dequeue sequence is { 1, 5, 4, 7, 6, 2, 3 }. If both the stack and the queue are initially empty, then the minimum size of the stack must be:

A.1B.2C.3D.4

1-5 D B C B A
6-10 B C B D C
11 C

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值