插入排序之折半插入排序
摘要:
折半插入排序时间复杂度O(n^2)附加空间O(1)稳定排序#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std; #define LEN 8 // 有LEN个元素要排 struct Record { // 为了考察排序的稳定性,定义元素是结构体类型 int key; int otherinfo;
}; void BInsertSort(Record *arr, int length) // length是要排序的元素的个数,0号单元除外
{ for (int i = 2; i <= le 阅读全文
posted @ 2012-05-19 21:09 jjtx 阅读(206) 评论(0) 推荐(0) 编辑