算法导论第三版英文答案

时间:2018-08-07 11:57:55
【文件属性】:

文件名称:算法导论第三版英文答案

文件大小:420KB

文件格式:PDF

更新时间:2018-08-07 11:57:55

算法导论答案

SELECTION-SORT.A/ n D A:length for j D 1 to n 1 smallest D j for i D j C 1 to n if AŒi < AŒsmallest smallest D i exchange AŒj with AŒsmallest The algorithm maintains the loop invariant that at the start of each iteration of the outer for loop, the subarray AŒ1::j 1 consists of the j 1 smallest elements in the array AŒ1::n, and this subarray is in sorted order. After the first n 1 elements, the subarray AŒ1::n 1 contains the smallest n 1 elements, sorted, and therefore element AŒn must be the largest element.


网友评论