【拓展题】三路快速排序
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Background
三路快速排序的实现
Description
完成下述三路快速代码框架后提交,只需完成注释中的要求,无需输入输出
#include "ThreeWayQuickSort.h"
void ThreeWayQuickSort::three_way_quick_sort(std::vector<int>& nums, int p, int q) {
// 请在这里完成你的代码
}
void ThreeWayQuickSort::mysort(std::vector<int>& nums) {
if(nums.size() == 0)
return;
three_way_quick_sort(nums, 0, nums.size() - 1);
}
Samples
提供一组样例用于自测
6
5 2 4 2 3 1
1 2 2 3 4 5
附ThreeWayQuickSort.h
#pragma once
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <functional>
using namespace std;
class MySort {
public:
virtual void mysort(std::vector<int>& nums) = 0;
};
class ThreeWayQuickSort: public MySort {
public:
// 通过三路快速排序对int数组nums进行升序排序
// @param
// nums: 完整的待排序队列,最终排序的结果应存放在nums中
void mysort(std::vector<int>& nums);
void three_way_quick_sort(std::vector<int>& nums, int p, int q);
};
实验三 堆排序、快速排序与队列
- Status
- Done
- Problem
- 5
- Open Since
- 2024-10-7 14:00
- Deadline
- 2024-10-7 17:30
- Extension
- 144 hour(s)