[问题] 100台联大系统堆叠问题

楼主: lkjh775533 (考得火热)   2012-06-15 21:30:22
5.What is the top element of Stack S after execution of the pseudocode
program on the below?
Stack(S);//create a stack S
Queue(Q);//create a queue Q
Push(S,1);Push(S,2);
Push(S,3);Push(S,4);
Enqueue(Q,5);Enqueue(Q,6);
for(i=1 to 4){
x=Pop(S);
Enqueue(Q,x);
}
for(i=1 to 6){
x=Dequeue(Q);
Push(S,x);
}
a.4 b.3 c.2 d.1 e.None of the above
我认为答案的关键在top element of Stack
另一题也是台联100
25.A stack is initially empty, then the following commands are performed:
push 5
push 7
pop
push 10
push 5
pop
Which of the following is correct stack after those commands(assume the top
of the stack is on the left)?
我认为答案的关键在也top element of Stack
所以能否请版上高手讲解一下何谓堆叠顶端?如何去判别?谢谢大家!!
ps:A4的同志加油 实力才是唯一的靠山!!
楼主: lkjh775533 (考得火热)   2012-06-15 21:41:00
25题选项忘了打a.5 10 7 5 b.5 10 c.7 5 d.10 5
作者: hatvito (跳~跳~跳)   2012-06-15 23:30:00
答案是D B 吗?
楼主: lkjh775533 (考得火热)   2012-06-15 23:45:00
是的,可请帮忙讲解一下?万分感激!
作者: fb74123698 (PP瑄)   2012-06-29 15:33:00
第25题 为什么不是10 5

Links booklink

Contact Us: admin [ a t ] ucptt.com