英文版数据结构算法题.doc
![资源得分’ 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)
《英文版数据结构算法题.doc》由会员分享,可在线阅读,更多相关《英文版数据结构算法题.doc(7页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1. Suppose we have a linked list.Eack node has three parts: one data field and two linked fields.The list has been linked by the first linked field link1,but the list is disorder.Try your best to sort the list with the second linked field into an increasing list.算法:int creasort(struct node &head)if
2、(head1 = NULL)/没有结点return ERROR;head2 = head1;/设排列链表的第一个结点head2-link2 = NULL;p = head1-link1;/p为链表的第二个结点q = head;/q代表p插入位置的前一个结点if (!p)/只有一个结点return OK;while (p)while ( q-link2 & (q-link2-data data)/找查找入位置q = q-link2;if (!q-link2)/插在最后q-link2 = p;else /插在队列中间p-link2 = q-link2;q-link2 = p;p = p-link1
3、;q = head;return OK;2. Suppose we have a sequence with the terminal character .The format of the sequence can be S1&S2,S1 and S2 do not contain &, S2 is the reverse sequence of S1.Try to write an algorithm to check the sequence if the format of the sequence obeys the above fules then the function re
4、turn TRUE otherwise FALSE.算法:/s为待检查的字符串int checkrules(char *s)len = strlen(s);/用string.h自带函数取字符串s的长度if (len % 2 = 0)/字符串是偶数return FALSE;i = 0;/i指向字符串第一个字符n = len - 1;/n指向字符串最后一个字符while (i L.data)/无效的访问return;p = &L;/定位,p指向已经访问的指针while(x-)p = p-next;p-freq+;/因为形参L不在循环链表里,因此要用L.pre-next表示循环链表的头结点while
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 英文 数据结构 算法
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内