面试准备-《算法第4版》Java算法笔记、理解整理

年假之前,我就规定自己要完成多少多少的任务,要做一些些有意义的事情,读书,练习,输出一些有价值的文字和笔记正是这一理念的实现,这样不仅让自己的经历更漂亮一点,也能帮助很多其他人!

JVM 是 java 程序员永远的考题,算法是所有程序员永久的考题。这应该是很多人的共识,不管是谁,学习的路上我们时常遇到迷茫阶段,抓住最根本的东西你永远不会觉得迷失。

《算法(第4版)》是一本晦涩的书,特别是中文版!我要强烈吐槽一下中文版的翻译,因为这本书业内评价都极高,当我兴致勃勃准备开始复习时,却被绕口的中文读的喘不过气,导致我推迟好久终于在今年年假期间才又拿出来慢慢对着英文原版啃起来!

除去基础数据结构的介绍,从大的方面讲,全书共有 4 大块,分别是排序、搜索、图、字符串,每大块基本都有 5 节的内容,每节又会有 4~5 种算法的实现与讲解,总共超过 80 道算法类型,图文并茂,确实是本好书(除了翻译)。

我希望能用这种方式激励我自己把这本书啃完,也希望帮助到一些正在准备面试和同样准备复习算法的同学。笔记内容除去了书中晦涩难懂的部分,截取的书中精华部分,我认为这本书的精华就是一张张插图,所以我几乎把所有的帮助理解的图都用上了,这一点你可以看3-3-平衡查找树的笔记,其次是每段都会贴出相应的关键代码,以便让我以后复习时不理解可以直接看代码。这本笔记在我反复复习也会随时更新,预计以后刷 LeetCode 时,也会将对应提醒放在对应章节里,如果有其他建议欢迎提 issue ,如果对你有帮助的话 Star 哦。

github整理地址:github.com/MeandNi/Alg…

笔记目录

书中所有算法集合

排序

ALGORITHMCODEIN PLACESTABLEBESTAVERAGEWORSTREMARKS
选择排序Selection.java½ n 2½ n 2½ n 2n exchanges; quadratic in best case
插入排序Insertion.javan¼ n 2½ n 2use for small or partially-sorted arrays
冒泡排序Bubble.javan½ n 2½ n 2rarely useful; use insertion sort instead
希尔排序Shell.javan log3 nunknownc n 3/2tight code; subquadratic
合并排序Merge.java½ n lg nn lg nn lg nn log n guarantee; stable
快速排序Quick.javan lg n2 n ln n½ n 2n log n probabilistic guarantee; fastest in practice
堆排序Heap.javan2 n lg n2 n lg nn log n guarantee; in place

优先队列

DATA STRUCTURECODEINSERTDEL-MINMINDEC-KEYDELETEMERGE
数组BruteIndexMinPQ.java1nn11n
二叉堆IndexMinPQ.javalog nlog n1log nlog nn
d-way heapIndexMultiwayMinPQ.javalogd nd logd n1logd nd logd nn
二项堆IndexBinomialMinPQ.java1log n1log nlog nlog n
斐波那契堆IndexFibonacciMinPQ.java1log n11 †log nlog n

查找

worst caseaverage case
DATA STRUCTURECODESEARCHINSERTDELETESEARCHINSERTDELETE
顺序查找 (无序列表)SequentialSearchST.javannnnnn
二分查找 (有序列表)BinarySearchST.javalog nnnlog nnn
二叉树 (不平衡)BST.javannnlog nlog nsqrt(n)
红黑二叉树 (左倾)RedBlackBST.javalog nlog nlog nlog nlog nlog n
散列表 (分离链接法)SeparateChainingHashST.javannn1 †1 †1 †
散列表 (线性探测)LinearProbingHashST.javannn1 †1 †1 †

PROBLEMALGORITHMCODETIMESPACE
路径DFSDepthFirstPaths.javaE + VV
最短路径(最少边缘)BFSBreadthFirstPaths.javaE + VV
DFSCycle.javaE + VV
有向路径DFSDepthFirstDirectedPaths.javaE + VV
最短有向路径 (最少边缘)BFSBreadthFirstDirectedPaths.javaE + VV
有向环DFSDirectedCycle.javaE + VV
拓扑排序DFSTopological.javaE + VV
bipartiteness / odd cycleDFSBipartite.javaE + VV
连通分量DFSCC.javaE + VV
强连通分量Kosaraju–SharirKosarajuSharirSCC.javaE + VV
强连通分量TarjanTarjanSCC.javaE + VV
强连通分量GabowGabowSCC.javaE + VV
欧拉回路DFSEulerianCycle.javaE + VE + V
定向欧拉循环DFSDirectedEulerianCycle.javaE + VV
传递闭包DFSTransitiveClosure.javaV (E + V)V 2
最小生成树KruskalKruskalMST.javaE log EE + V
最小生成树PrimPrimMST.javaE log VV
最小生成树BoruvkaBoruvkaMST.javaE log VV
最短路径(非负权)DijkstraDijkstraSP.javaE log VV
最短路径(无负循环)Bellman–FordBellmanFordSP.javaV (V + E)V
s最短路径(无环)topological sortAcyclicSP.javaV + EV
所有节点对之间的最短路Floyd–WarshallFloydWarshall.javaV 3V 2
最大流/最小割Ford–FulkersonFordFulkerson.javaE V (E + V)V
二分图匹配Hopcroft–KarpHopcroftKarp.javaV ½ (E + V)V
任务分配问题successive shortest pathsAssignmentProblem.javan 3 log nn 2
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This fourth edition of Robert Sedgewick and Kevin Wayne’s Algorithms is the leading textbook on algorithms today and is widely used in colleges and universities worldwide. This book surveys the most important computer algorithms currently in use and provides a full treatment of data structures and algorithms for sorting, searching, graph processing, and string processing--including fifty algorithms every programmer should know. In this edition, new Java implementations are written in an accessible modular programming style, where all of the code is exposed to the reader and ready to use. The algorithms in this book represent a body of knowledge developed over the last 50 years that has become indispensable, not just for professional programmers and computer science students but for any student with interests in science, mathematics, and engineering, not to mention students who use computation in the liberal arts. The companion web site, algs4.cs.princeton.edu, contains An online synopsis Full Java implementations Test data Exercises and answers Dynamic visualizations Lecture slides Programming assignments with checklists Links to related material The MOOC related to this book is accessible via the "Online Course" link at algs4.cs.princeton.edu. The course offers more than 100 video lecture segments that are integrated with the text, extensive online assessments, and the large-scale discussion forums that have proven so valuable. Offered each fall and spring, this course regularly attracts tens of thousands of registrants. Robert Sedgewick and Kevin Wayne are developing a modern approach to disseminating knowledge that fully embraces technology, enabling people all around the world to discover new ways of learning and teaching. By integrating their textbook, online content, and MOOC, all at the state of the art, they have built a unique resource that greatly expands the breadth and depth of the educational experience.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值