快速排序python及动画演示
时间: 2023-11-24 14:50:28 浏览: 81
快速排序python
以下是快速排序的Python代码和动画演示:
快速排序Python代码:
```python
def quick_sort(arr):
if len(arr) <= 1:
return arr
pivot = arr[0]
left = [x for x in arr[1:] if x < pivot]
right = [x for x in arr[1:] if x >= pivot]
return quick_sort(left) + [pivot] + quick_sort(right)
```
快速排序动画演示:
<iframe width="560" height="315" src="***="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
阅读全文