问答题

阅读以下算法说明,根据要求回答问题1~问题3。
[说明]
快速排序是一种典型的分治算法。采用快速排序对数组A[p..r]排序的3个步骤如下。
1.分解:选择一个枢轴(pivot)元素划分数组。将数组A[p..r]划分为两个子数组(可能为空)A[p..q-1]和A[q+1..r],使得A[q]大于等于A[p..q-1]中的每个元素,小于A[q+1..r]中的每个元素。q的值在划分过程中计算。
2.递归求解:通过递归的调用快速排序,对子数组A[p..q-1]和A[q+1..r]分别排序。
3.合并:快速排序在原地排序,故无需合并操作。
下面是快速排序的伪代码,请将空缺处(1)~(3)的内容填写完整。伪代码中的主要变量说明如下。
A:待排序数组
p,r:数组元素下标,从p到r
q:划分的位置
x:枢轴元素
i:整型变量,用于描述数组下标。下标小于或等于i的元素的值,小于或等于枢轴元素的值
j:循环控制变量,表示数组元素下标

A..r]排序的3个步骤如下。
B.分解:选择一个枢轴(pivot)元素划分数组。将数组A[p..r]划分为两个子数组(可能为空)A[p..q-1]和A[q+1..r],使得A[q]大于等于A[p..q-1]中的每个元素,小于A[q+1..r]中的每个元素。q的值在划分过程中计算。
C.递归求解:通过递归的调用快速排序,对子数组A[p..q-1]和A[q+1..r]分别排序。
D.合并:快速排序在原地排序,故无需合并操作。
下面是快速排序的伪代码,请将空缺处(1)~(3)的内容填写完整。伪代码中的主要变量说明如下。
E.shangxueba.cn/images/ct_csrmsdxm_crmsdxzuti_00028(20101).jpg'
题目列表

你可能感兴趣的试题

单项选择题

听力原文:W: Congratulations on your second album Love Is My Religion.
M: Thank you.
W: The message of love and friendship seems to be a running theme.
M: It was some stuff I was writing about that came together. I wasn't meaning to write about those themes.
W: So it wasn't a conscious decision to write about friendship and love?
M: No, no. I wanted to write an album that was more spiritual, more emotional.
W: Does that reflect where you were at the time you were writing the album?
M: We're trying to be. We're trying to get feeling of the alignment of the planets.
W: How long did it take you to record Love Is My Religion?
M: It took one year to record the album.
W: Was it shorter or longer than your previous efforts?
M: That's about the same.
W: Was it more difficult than your previous albums?
M: No, it's more spiritual. That's what it's all about. There was more opportunity to realize that we're not alone in our existence. There's a lot more happening when you're alone in an environment. You can actually perceive the things you wouldn't perceive if you were around a bunch of people.
W: So you prefer to work alone? So do I.
M: Some people don't work like that. They don't like to be alone.
W: I understand you played most, if not every, instrument on the album.
M: Not every. I played a lot. I had an engineer working with me, Ross, who played some instruments, too.
W: That must have been a lot of work.
M: It's not work. It's great fun. It's great enjoyment. It's experimentation and mystique that worked.
(20)
A.The man meant to write about the theme.
B.It was an eternal theme in the man's album.
C.It was about love between parents and children.
D.It was something that came naturally.

A.
M:
B.
W:
C.
M:
D.
W:
E.
W:
F.
W:
G.
W:
H.
W:
I.
W:
J.
M:
K.
W:
L.
M:
M.
W:
N.
M:
O.
(20)
A.The
P.
B.It
Q.
C.It
R.
D.It
S.
微信扫码免费搜题