2023年数据结构实验互联网域名查询实验报告.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2023年数据结构实验互联网域名查询实验报告.docx》由会员分享,可在线阅读,更多相关《2023年数据结构实验互联网域名查询实验报告.docx(10页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、实验报告实验课程:数据结构实验项目:实验三互联网域名查询专业:计算机科学与技术班经姓 枚学 指导教师:。s t r cpy(X-data, Z hongZ hu a n);/将中转数组的信息复制给待插入节B = (CSTr e e)mallo c (si z eoffCSNod e );o。B-f i r s t c h i 1 d = B-nex t s i bling = NULL;)。 el s e(if (X-firstchild)0 o o |3strep y (B- d a t a, ZhongZh u an);。 X-next sibling = B; 将B作为X的兄弟节点。B
2、= (CSTree) mallocf s i z e o f (CSNo de);。B-f i rstchi 1 d = B- n exts i bl i ng = NULL;s X= X ne x ts i blin g; /x指向它的兄弟节点。 )el s e0 o 。 str c p y (B- d a taz ZhongZh u a n );。 oXfi r stch i 1 d = B; B = (CSTre e )malloc( s izeo f (C S No d e);o。B-firstc h ild = B-ne x t s ibling = NULL;。X = X fi r
3、stchi 1 d;0 o o jsos t r u ct Queue 3 int Top, Tail;-CSNode*a 1 000;v oid C lear();voi d Push(C S Node *e); void Pop();C S Node * Fro nt ();bool Em p ty();/队列封装为结构体v oi d Qu e u e :CI e ar() 0 Top =Tai 1 = 0;are turn;/清空队列void Qu e u e : :Push (CSNode *e)a a(Tail+ = e;3 return; 入队列v o id Qu e ue:Pop
4、() T o p +;。return;/出队列CSNode *Q u eue: F ront() o r e tur n a Top;/取队首元素b ool Queue: :Em p ty() r e t u rn Top = T a il;) 判空void BFSfCSNod e *ro o t) printf (层次优先搜索遍历结果为:n”);Q u e ue qu e ;q u e . Clear ();3 q u e. p ushfroo t ) ; / /根节点入队列w hile(!que. empty() )/队列不空的时候执行循环。CS Nod e * x x = q u e.f
5、ro nt();/取队首元素que.pop(); / / 出队列, printf(%sn, xx d a t a );。if (xx-nextsibling) /出队节点的孩子节点若不空则入队列。q ue.push(xx-nexts i bling);if (xx-f i rstch i Id) /同样若孩子节点不空则入队列3 oque. p u s h(xx f irst c hil d );o)vo i d DFS(CS Node * roo t ) 8 if (koot)retum; 递归结束条件。pr i ntf( %sn , r oot-da t a);。D F S( r oot-f
6、ir s tchild);/ / 递归遍历孩子节点DFS(ro o t-ne x t s ib 1 in g ) ;/ / 递归遍历兄弟节点int main()(nt j ;CSNod e *A;A = (C SNod e *) mallo c (sizeof(CSNod e ); / /根节点创建A-fir s tchild = A-nextsibli n g = NULL;A-da t a0 = O;c h ar b30; /定义字符数组接受域名。char *s;for (j = 0; j 域名拆分 根据孩子兄弟链表表达的树进 行插入 调用层次优先遍历输出遍历结果调用深度优先遍历输出遍历结
7、果结束程序模块关系:输I:域名创建孩子兄弟树层次优I先遍历输出结果深厚优先遍历输出结果结束三、具体设计孩子兄弟链表结构:typ e d e f struct CSNodeE 1 e mT y pe data 10;st r u c t CSNod e *fi r s tchi 1 d, * nextsi b I i ng;*CSTree;模块一深度优先遍历算法如下void DF S (CSNode *root) iff! root) r e turn; 递归结束条件prin t f (sn,roo t -d a ta);DFS (roo t -f i rstchild); /递归遍历孩子节点o
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2023 数据结构 实验 互联网 域名 查询 报告
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内