CS-Notes/interview/struct/algorithm.md
xiongraorao 23956d6bea 1
2018-09-10 11:50:48 +08:00

29 lines
990 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 大顶堆和小顶堆
比如求10亿个数中的最大的前10个数时时构建只有10个元素的小顶堆如果比堆顶小则不处理如果比堆顶大则替换堆顶然后依次下沉到适当的位置。
比如求10亿个数中的最小的前10个数时时构建只有10个元素的大顶堆如果比堆顶大则不处理如果比堆顶小则替换堆顶然后依次下沉到适当的位置。
# 堆排序的原理
- [图解排序算法(三)之堆排序](https://www.cnblogs.com/chengxiao/p/6129630.html)
# 求TOPk的问题
1. 使用小顶堆求Topk
2. 使用快速查找法找到第K大的元素剩下的一边就是topK
3. 全排序
# KMP算法
一种字符串查找算法
参考链接:
- [从头到尾彻底理解KMP](https://blog.csdn.net/v_july_v/article/details/7041827)
- [阮一峰讲解](http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html)
# LRU实现
最小访问的算法实现