Skip to content

Commit

Permalink
提交笔记
Browse files Browse the repository at this point in the history
  • Loading branch information
ecustsw committed Jul 12, 2020
1 parent e111fa5 commit a0893c8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AlgoTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@
<ItemGroup>
<None Include="readme" />
</ItemGroup>
<ItemGroup>
<Text Include="算法基础点.txt" />
<Text Include="算法过程.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions AlgoTest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@
<Filter>源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="算法过程.txt">
<Filter>源文件</Filter>
</Text>
<Text Include="算法基础点.txt">
<Filter>源文件</Filter>
</Text>
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions 算法基础点.txt
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的点
每次选择时,选择答案所在的区间,边界点不丢失
12 changes: 12 additions & 0 deletions 算法过程.txt
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

0 comments on commit a0893c8

Please sign in to comment.