/Algorithms

Code from the book "Algorithms" (4th ed.) by Robert Sedgewick and Kevin Wayne (original, and my solutions to exercises).

Primary LanguageJava

The following data files are missing from this repository, due to their large size:

File Size Used by


leipzig1M.txt 129.6 MB 3-Searching UPC.csv 48.1 MB 3-Searching largeUF.txt 25.8 MB 1-Fundamentals largeT.txt 7.0 MB 1-Fundamentals largeW.txt 7.0 MB 1-Fundamentals movies.txt 3.4 MB 3-Searching, 4-Graphs mobydick.txt 1.2 MB 6-Context DJIA.csv 1.1 MB 3-Searching

An archive that contains these data files (as well as all the other ones used in the book) can be found at: http://algs4.cs.princeton.edu/code/algs4-data.zip

题目:菲波拉契数列问题 古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?

题目:判断101-200之间有多少个素数,并输出所有素数。 程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除, 则表明此数不是素数,反之是素数。

题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三次方+5的三次方+3的三次方。