2012年1月4日

极度简化版 HeapSort

摘要: 看了网上很多HeapSort版本实现都很复杂,其实HeapSort是完全可以只用一个循环在10行内解决的,先上代码:void heapsort(int* array, int size) { int top = size; int bot = size; int cur; int nxt = size; while(cur = nxt, bot > 0) { if(cur * 2 + 1 < bot && array[nxt] < array[cur * 2 + 1]) nxt = cur * 2 + 1; if(cur * 2 + 2... 阅读全文

posted @ 2012-01-04 12:22 RichSelian 阅读(1724) 评论(2) 推荐(2) 编辑

导航