标题:[求助]三个算法
只看楼主
fangfangff
Rank: 1
等 级:新手上路
威 望:2
帖 子:479
专家分:0
注 册:2006-12-22
 问题点数:0 回复次数:2 
[求助]三个算法
一.利用线性表的基本操作实现两个元素交换的算法.
二.求字符串出现次数最多的一个子串,串插入函数.
三.两个有序的单链表的归并算法....

现在哪个有空帮帮忙做一下这三个算法好吗??
谢谢哈!!!
搜索更多相关主题的帖子: 线性表 字符串 元素 
2007-07-05 20:42
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
得分:0 
回复:(fangfangff)[求助]三个算法

> 一.利用线性表的基本操作实现两个元素交换的算法.
Are you saying you are swapping the data of two nodes?

> 二.求字符串出现次数最多的一个子串,串插入函数.
What does it mean by ",串插入函数."? Should it be there?

This could be a single char whihch appears most frequently. Say
"aaabbaaabbbbbbbbbbbbbbbbbbbbbbbbbbbcc"
then,
"b" is the one, or "bb" is the one...

My point is the problem statement is not clear.

> 三.两个有序的单链表的归并算法....

Following code is for two sorted arrays a and b, they are merged into array c.
I would think you can modify it for two sorted singly linked lists.


void merge(int* a, int na, int* b, int nb, int* c)
{
int ai=0, bi=0, ci=0;

while(ai<na && bi<nb) // both a and b are not empty
if(a[ai]<b[bi])
c[ci++] = a[ai++];
else
c[ci++] = b[bi++];

while(ai<na) // a is not empty, but b is
c[ci++] = a[ai++];

while(bi<nb) // a is empty, but b is not
c[ci++] = b[bi++];
}


I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-07-06 09:07
fangfangff
Rank: 1
等 级:新手上路
威 望:2
帖 子:479
专家分:0
注 册:2006-12-22
得分:0 
回复:(HJin)回复:(fangfangff)[求助]三个算法
一.利用线性表的基本操作实现两个元素交换的算法

二.求字符串出现次数最多的一个子串

三.两个有序的单链表的归并算法....

题目就是这样了,那个"串插入函数."我也不太明白
所以我也想麻烦你帮忙写一下啊!!!
呵呵

谢谢你哈!!!
你的英语好强哦,都是用英语回答我,
我都看得不太明白啊!!!!

千里冰封---My Love 尽管相隔千里 , 依然拥有冰封
2007-07-06 11:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-153069-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.205778 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved