Skip to content

Commit 8531225

Browse files
committedOct 10, 2019
update readme
1 parent 9729985 commit 8531225

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
 

‎README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## 目录
22

33
### 基本数据结构
4-
4+
- [数组]()
5+
- [链表](./Linked_list)
56
#### TODO:
67
- [](./Heap)
78
- [](./Stack)
@@ -11,6 +12,12 @@
1112
- [双端队列](./Deque)
1213

1314
### 基本排序算法
15+
- [快速排序](sorts/quick_sort)
16+
- [冒泡排序](sorts/bubble_sort)
17+
- [插入排序](sorts/insertion_sort)
18+
- [归并排序](sorts/merge_sort)
19+
- [选择排序](sorts/selection_sort)
20+
- [希尔排序](sorts/shell_sort)
1421

1522
### 其他数据结构
1623
#### TODO:

‎sorts/bubble_sort/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
## 图示
1616

1717
![冒泡排序算法](./img/Bubble_sort_animation.gif)
18+
1819
从图中可以看到,冒泡只有最上面的会保证顺序排列,剩下的(未排序元素)是逐渐(向有序)“靠拢”的过程。
1920

2021
![冒泡排序实例](./img/bubble_sort_example.gif)

‎sorts/quick_sort/quick_sort.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ def quick_sort(unsorted_collection):
2323
cmp_base = unsorted_collection[0] # 取出第一个作为比较基准
2424
left_col = [item for item in unsorted_collection[1:] if item <= cmp_base] # 如果希望降序排列,只需分治点两边调换即可
2525
right_col = [item for item in unsorted_collection[1:] if item > cmp_base]
26+
'''
27+
left_col = []
28+
right_col = []
29+
for item in unsorted_collection[1:]:
30+
left_col.append(item) if item <= cmp_base else right_col.append(item)
31+
'''
2632
return quick_sort(left_col) + [cmp_base] + quick_sort(right_col) # 对左右两边的序列使用递归,之后拼接;注意中间的元素要“还原”
2733

2834

0 commit comments

Comments
 (0)
Please sign in to comment.