测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A67625. 考虑以下C++代码实现的快速排序算法,将数据从小到大排序,则横线上应填的最佳代码是( )。1 int partition(vector<int>& arr, int low, int high) {

单选题

题目描述

考虑以下C++代码实现的快速排序算法,将数据从小到大排序,则横线上应填的最佳代码是( )

1 int partition(vector<int>& arr, int low, int high) {
2  int pivot = arr[high]; // 基准值 
3  int i = low - 1; 
4
5  for (int j = low; j < high; j++) { 
6   ________________________________ // 在此处填入代码 
7  } 
8  swap(arr[i + 1], arr[high]); 
9  return i + 1;
10 } 
11
12 // 快速排序 
13 void quickSort(vector<int>& arr, int low, int high) { 
14  if (low < high) { 
15   int pi = partition(arr, low, high); 
16   quickSort(arr, low, pi - 1); 
17   quickSort(arr, pi + 1, high); 
18  } 
19 }


选项(单选)