(六十三)第 10 章 内部排序(插入排序)
示例代码
insertionSort.h
// 插入排序的实现头文件#ifndef INSERTION_SORT_H
#define INSERTION_SORT_H#include "errorRecord.h"#define NUM 8
#define MAX_SIZE 20#define EQUAL(a, b) ((a) == (b))
#define LESS_THAN(a, b) ((a) < (b))
#define LESS_OR_EQUAL(a, b) ((a) <= (b))typedef int InfoType;
typedef int KeyType;typedef struct {KeyType key;InfoType info;
} RecType;typedef struct {RecType rec[MAX_SIZE + 1]; // 0 位置用作哨兵或闲置int length;
} SqList;/*算法 10.1前置条件:list 非空操作结果:对顺序表 list 作直接插入排序
*/
Status InsertSort(SqList *list);/*算法 10.2前置条件:list 非空操作结果:对顺序表 list 作折半插入排序
*/
Status BInsertSort(SqL