【发布时间】:2019-12-09 04:24:24
【问题描述】:
def selection_sort(a):
for i in range(0, len(a) - 1):
minIndex = i
for j in range(i + 1, len(a)):
if a[j] < a[minIndex]:
minIndex = j
if minIndex != i:
a[i], a[minIndex] = a[minIndex], a[i]
def selection_sort_runs():
run_time_list = []
n = 1
while [having trouble thinking of loop condition here]
start_time = time.time()
rand = [random.randint(0, 100) for x in range(1, 10001*n)]
selection_sort(rand)
end_time = time.time()
run_time = end_time - start_time
run_time_list.append(run_time)
if run_time < 60:
n += 1
我想继续循环直到 run_time 大于 60,但我想不出一个条件可以让我这样做并将 n 加一,因为 run_time 是包含在循环内的产品,有什么想法吗?
【问题讨论】:
标签: python python-3.x data-structures