2012年5月17日

二分法插入排序

摘要: #include "stdio.h"#include "malloc.h"typedef int KeyType;typedef int DataType;typedef struct { //排序码字段 KeyType key; //记录的其他字段 DataType info;}RecordNode;typedef struct{ int n; RecordNode * record;}SortObject;void binSort(SortObject * pvector){ int i,j,left,right,middle; Record... 阅读全文

posted @ 2012-05-17 22:41 yucong 阅读(387) 评论(0) 推荐(0)

直接插入排序算法

摘要: 代码分析:直接插入排序算法的平均移动次数与平均比较次数同级,都是O(n²),所以,直接插入排序的平均时间复杂度为T(n)=O(n²)。算法中引入了一个附加的记录空间temp,因此辅助空间为S(n)=O(1).直接插入排序是稳定的。#include "stdio.h"#include "malloc.h"typedef int KeyType;typedef int DataType;typedef struct { //排序码字段 KeyType key; //记录的其他字段 DataType info;}RecordNode;typ 阅读全文

posted @ 2012-05-17 21:34 yucong 阅读(365) 评论(0) 推荐(0)

导航