数据结构第3章练习.pdf

上传人:苏美尔 文档编号:8844905 上传时间:2021-01-19 格式:PDF 页数:2 大小:73.72KB
返回 下载 相关 举报
数据结构第3章练习.pdf_第1页
第1页 / 共2页
数据结构第3章练习.pdf_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《数据结构第3章练习.pdf》由会员分享,可在线阅读,更多相关《数据结构第3章练习.pdf(2页珍藏版)》请在三一文库上搜索。

1、第第三三章章作业作业 2012-10-08 1 1、 假设一个假设一个顺序栈的栈顶、栈底指针顺序栈的栈顶、栈底指针分别为分别为toptop和和basebase, ,则判断则判断栈栈空的条件为空的条件为 ( D D ) 。) 。 A Abase!base!= =NULLNULL B.B. top=top=NULL=NULL C.C. base=base=NULL=NULL D. topD. top=basebase 2 2、 假设一个带头节点链队的队首和队尾指针分别为假设一个带头节点链队的队首和队尾指针分别为frontfront和和rear,rear,则判断队空的条则判断队空的条 件为(件为(

2、A A ) 。) 。 A Afront=rearfront=rear B.B. front!=NULLfront!=NULL C.rear!=NULLC.rear!=NULL D. D. front=NULLfront=NULL 3 3、 假设一个假设一个循环顺序循环顺序队队列列Q Q的队首和队尾指针分的队首和队尾指针分别为别为frontfront和和rear,rear,队列最大存储值队列最大存储值 为为Max,Max,则判断队空的条件为(则判断队空的条件为( B B ) ,队满的条件为(,队满的条件为( D D ) 。 A A)front=NULL)front=NULL B B)Q.fron

3、t=Q.rear)Q.front=Q.rear C C) )rearrear= =NULL=NULL D D)(rear+1)%Max=front)(rear+1)%Max=front 4 4、 写出下列程序段的结果写出下列程序段的结果 Void main() Stack S; Char x,y; InitStack(S); x=c;y=k; push(S,x); push(S,a); push(S,y); pop(S,x); push(S,t); push(S,x); pop(S,x); push(S,s); while(!StackEmpty(S) pop(S,y); printf(y);

4、 printf(x); stack 5 5、 简述下列算法的功能简述下列算法的功能 S Status algo2(Stack S, int e) tatus algo2(Stack S, int e) Stack T; Stack T; int d;int d; InitStack(T);InitStack(T); W While (!StackEmpty(S)hile (!StackEmpty(S) pop(S,d);pop(S,d); I If (d!=e)f (d!=e) pushpush(T,d);(T,d); W While (!StackEmpty(T)hile (!StackEm

5、pty(T) pop(T,d);pop(T,d); push(S,d);push(S,d); 利用栈利用栈T T辅助将栈辅助将栈S S中所有值为中所有值为e e的数据元素删除之。的数据元素删除之。 6 6、 写出下列程序段的结果写出下列程序段的结果 Void main() Queue Q; InitQueue(Q); Char x=e, y=c; Enqueue(Q, h); Enqueue(Q, r); Enqueue(Q, y); DeQueue(Q,x); Enqueue(Q, x); DeQueue(Q,x); DeQueue(Q,x); Enqueue(Q, a); while(!Q

6、ueueEmpty(Q) DeQueue(Q,y); printf(y); printf(x); hac 7 7、 简述下列算法的功能简述下列算法的功能 void algo3(Queue Stack S; int d;int d; InitStack(S);InitStack(S); W While (!QueueEmpty(Q)hile (!QueueEmpty(Q) DeQueue(Q,d);DeQueue(Q,d); Push(S,d);Push(S,d); W While (!StackEmpty(S)hile (!StackEmpty(S) Pop(S,d);Pop(S,d); EnQueue(Q,d);EnQueue(Q,d); 利用栈做辅助,将队列中的数据元素进行逆置。利用栈做辅助,将队列中的数据元素进行逆置。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1