高分 问一道算法题 英文的哦
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:英语作业 时间:2024/08/17 00:57:49
高分 问一道算法题 英文的哦
Suppose array A has N elements and is to be sorted in ascending order. This means that
A[ i ] ≤ A[ j ], when i < j. Two elements of the array, A[ i ] and A[ j ], form an inversion if
A[ i ] > A[ j ] and i < j.
Now suppose array A is actually sorted in descending order and that A contains no duplicate
elements. If A[ i ] and A[ i + k ], where 0 ≤ i < N – k, and 0 < k < N are swapped, what is
the maximum number of inversions removed as an expression in k? Justify your answer.
Suppose array A has N elements and is to be sorted in ascending order. This means that
A[ i ] ≤ A[ j ], when i < j. Two elements of the array, A[ i ] and A[ j ], form an inversion if
A[ i ] > A[ j ] and i < j.
Now suppose array A is actually sorted in descending order and that A contains no duplicate
elements. If A[ i ] and A[ i + k ], where 0 ≤ i < N – k, and 0 < k < N are swapped, what is
the maximum number of inversions removed as an expression in k? Justify your answer.
![高分 问一道算法题 英文的哦](/uploads/image/z/16831625-41-5.jpg?t=%E9%AB%98%E5%88%86+%E9%97%AE%E4%B8%80%E9%81%93%E7%AE%97%E6%B3%95%E9%A2%98+%E8%8B%B1%E6%96%87%E7%9A%84%E5%93%A6)
Suppose array A has N elements and is to be sorted in ascending order.This means that
假设数组A有N个元素,他们是按非降序排列的.这就是说
A[ i ] ≤ A[ j ],when i < j.Two elements of the array,A[ i ] and A[ j ],form an inversion if
当i A[ j ] 而且i < j.那么A[ i ] 和 A[ j ],形成了逆序对
A[ i ] > A[ j ] and i < j.
Now suppose array A is actually sorted in descending order and that A contains no duplicate
现在假设数组A是按降序排列的,而且A里面没有元素是相同的
elements.If A[ i ] and A[ i + k ],where 0 ≤ i < N – k,and 0 < k < N are swapped,what is
如果A[i]和A[i+k]交换(这里0 ≤ i < N – k,并且0 < k < N )
the maximum number of inversions removed as an expression in Justify your answer.
对于某个K,最多能减少多少对逆序对.证明你的结论.
再问: 我没让你翻译,我想求解
再答: the maximum number of inversions removed as an expression in k? 这句话什么意思我还不懂啊。能不能举个例子啊? 这个是算什么最大啊?是对于所有的K求最大还是对于某个具体的K啊? 如果是对于某个K的话,我们可以观察规律的 0 1 2 3 4 5 6 7 先看K=1的情况 0一直是往后面走的,其他的最后是位置不变,那么这里变化了6个 K=2的情况 0走过的位置是2 4 6 1走过3 5 7 对于某个K 最后的结果是 a[i] 0
假设数组A有N个元素,他们是按非降序排列的.这就是说
A[ i ] ≤ A[ j ],when i < j.Two elements of the array,A[ i ] and A[ j ],form an inversion if
当i A[ j ] 而且i < j.那么A[ i ] 和 A[ j ],形成了逆序对
A[ i ] > A[ j ] and i < j.
Now suppose array A is actually sorted in descending order and that A contains no duplicate
现在假设数组A是按降序排列的,而且A里面没有元素是相同的
elements.If A[ i ] and A[ i + k ],where 0 ≤ i < N – k,and 0 < k < N are swapped,what is
如果A[i]和A[i+k]交换(这里0 ≤ i < N – k,并且0 < k < N )
the maximum number of inversions removed as an expression in Justify your answer.
对于某个K,最多能减少多少对逆序对.证明你的结论.
再问: 我没让你翻译,我想求解
再答: the maximum number of inversions removed as an expression in k? 这句话什么意思我还不懂啊。能不能举个例子啊? 这个是算什么最大啊?是对于所有的K求最大还是对于某个具体的K啊? 如果是对于某个K的话,我们可以观察规律的 0 1 2 3 4 5 6 7 先看K=1的情况 0一直是往后面走的,其他的最后是位置不变,那么这里变化了6个 K=2的情况 0走过的位置是2 4 6 1走过3 5 7 对于某个K 最后的结果是 a[i] 0