-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
1 快速排序(基于分治法)区间[l,r] | ||
确定分界点x | ||
调整区间,使左半边的数都小于等于x,右半边的数都大于等于x(边界问题的处理,模板的使用,可以减少出问题的风险) | ||
递归处理左右两半边 | ||
|
||
边界问题造成的死循环:每次分治后,区间大小不变。 | ||
|
||
2 归并排序 分治法 区间[l,r] | ||
递归排序左右半边 | ||
归并左右半边 | ||
时间复杂度:稳定的nlogn (logn层,每层都是O(n)的复杂度) | ||
|
||
排序的稳定性,对相同的数,排好序之后的序列中的相对位置和原序列中的相对位置相同 | ||
|
||
3 整数二分 区间[l,r] | ||
有单调性一定可以二分,二分的场景不一定需要有单调性 | ||
本质是用来找边界,这个边界在左半边区间是满足的,在右半边区间是不满足的。因是整数区间,所以两个区间没有交点 | ||
对应两个点:最后一个满足条件1的点,第一个满足条件2的点 | ||
每次选择时,选择答案所在的区间,边界点不丢失 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
序列 l r 划分点 | ||
3 1 2 4 5 0 4 f[l] | ||
2 1 3 4 5 | ||
2 1|3 4 5 | ||
|
||
|
||
1 6 8|4 5 | ||
|
||
1 4 5 6 8 | ||
|
||
3 1 2 4 5 | ||
1 3 2 4 5 |