摘要: 1、时间复杂度:O(NlogK)。 std::vector<int> arr = {10, 3, 5, 6, 2, 3, 112, 35}; std::priority_queue<int, std::vector<int>, std::greater<int> > q; // std::prior 阅读全文
posted @ 2020-03-19 15:50 happyyoung 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1、时间复杂度:O(N^N)。 2、算法实现 2.1)每趟需要把无序区间的最大的数放到尾部,所以最多需要N-1趟; 2.2)第i趟的无序区间是[0, N-1-i]。 2.3)无序区间的相邻元素两两比较,满足条件则交换。 void bubble_sort(std::vector<int> &arr) 阅读全文
posted @ 2020-03-19 14:37 happyyoung 阅读(174) 评论(0) 推荐(0) 编辑