实验五查找及排序
![实验五查找及排序](https://img.360docs.net/imgbe/1m9r5n9s32n0sowzaficbrn3ihu2meeh-e1.webp)
![实验五查找及排序](https://img.360docs.net/imgbe/1m9r5n9s32n0sowzaficbrn3ihu2meeh-a2.webp)
实验五查找及排序实验课程名:数据结构与算法
(3)运行结果分析:
运用顺序结构完成查询。
任务二:哈希表的开放定址法算法。在输出结果中显示查找成功与查找不成功信息。
解答:
(1)源代码:#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// 函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
// #define OVERFLOW -2 因为在math.h中已定义OVERFLOW的值为3,故去掉此行
(2)运行结果:
(3)运行结果分析:
运用哈希表开放定地址算法实现。
任务三:各种插入排序算法的实现。
解答:
(1)源代码:#include
#include
#include
#include
#include
#include
(3)运行结果分析
运用直插、折半插、路插的方法编写。
三、实验小结
通过本次实验我知道了查找的不同方法,并能用高级语言实现查找算法,并且掌握顺序表的查找方法和有序顺序表的折半查找算法,了解了常用的排序方法,并能用高级语言实现排序算法。
相关主题