举例:
算法属性:
时间复杂度为O(n^2)
空间复杂度为O(1)
稳定排序。
当初始记录无序,n较大时,此算法时间复杂度较高,不宜采用。
代码如下:
#include<stdio.h>
#define MAXSIZE 20
typedef int KeyType;
typedef int InfoType;
typedef struct {
KeyType key;
InfoType otherinfo;
}RedType;
typedef struct {
RedType r[MAXSIZE + 1]