1、创新工场2014笔试算法题汇总1. 堆排序1.#include 2.usingnamespace std; 3. 4.void SwapValue(int &m, int &n) 5.{ 6. int temp = m; 7. m = n; 8. n = temp; 9.} 10.void max_heap(vector &vec, int i, int heap_size) 11.{ 12. int l =
2、 2*i; 13. int r = 2*i+1; 14. int largest = i; 15. 16. if(l<=heap_size && vec[l-1]>vec[largest-1]) 17. largest = l; 18. if(r<=heap_size && vec[r-1]>vec[largest-1]) 19. largest = r; 20. 21. if(largest!=i) 22