【发布时间】:2021-08-24 12:52:27
【问题描述】:
我需要一些帮助来计算跳跃搜索算法的复杂度
对不起,它说我需要写更多信息来分享我的问题,所以请忽略这个,我真的需要它。
void jump_search(Pointeur_L1 P, int lenght, char * word) {
Pointeur_L1 inf, max;
max = P;
lenght = longueur_L1(P);
int step = sqrt(lenght);
bool r = false;
int i, j = 0;
while (j < longueur_L1(P)) {
for (i = 0; i < step; i++) {
max = max -> suiv;
}
if (strcmp(max -> mot, word) == 0) {
printf("ce mot existe :");
printf("dans la ligne %d a la position %d \n", max -> line, max -> pos);
r = true;
}
if (strcmp(max -> mot, word) > 0) {
while (max != NULL) {
if (strcmp(max -> mot, word) == 0) {
printf("ce mot existe :");
printf("dans la ligne %d a la position %d \n", max -> line, max -> pos);
r = true;
max = max -> preced;
} else {
max = max -> preced;
}
}
} else {
inf = max;
}
j++;
}
if (max == NULL) {
printf("ce mot n existe pas\n");
}
}
【问题讨论】:
-
如何计算不同输入大小的复杂性(或分析运行时)以获得第一个想法?
-
我说我需要帮助来计算复杂性我没有代码错误
-
“我没有代码错误”:代码有错误。尝试使用四个值的列表:2->4->6->8,然后搜索值 9。
标签: c list algorithm function sorting