1. preface /**** * This article will try to explain something about: * --Bubble sort. * --Quick sort. * --Merge sort. * --Heap sort. * To read this, some prerequisites is necessary: * --a survive skill in C pr
一.合并已排序的两个数组,依次比较两个数组元素大小,并按大小加入到暂存数组B,最后保存到A: Algorithm: MERGE(A, p, q, r) 输入:数组A[p...q]和A[q+1...r],各自按升序排列 输出:将A[p...q]和A[q+1...r]合并后的升序排序的新数组 01. s←p; t←q+1; k←p; {s, t, p 分别指向A[p...q], A[q+1...r]和暂存数组B} 02. while s≤q and t≤r 03. if A[s] ≤A[t] the