This is a implement of Algorithms 4th Edition(Princeton) by Python3.
- Please download the algs4-data package from the office site, then make sure the directory tree like this:
algorithms/
|
--algs4-data/
|
--1Kints.txt
|
--2Kints.txt
|
--......
- I use
open('path')
function as input instead of streams of Linux, so please do not use<
to input data. You can run program like this:
pyalgs4$ python TopM_2.6.py 5 ./algs4-data/tinyBatch.txt
According to Algorithms 4th Edition, these algorithms are implemented by Java, but I hardly use Java. So I decided to implement these algorithms by Python.
Because of an apparent lack of programming skills, these codes still have to be improved, welcome to submit issues anytime.
此为《算法(第四版)》(普林斯顿大学)一书的Python实现。
- 请从官网下载algs4-data包,并确保目录树如下:
algorithms/
|
--algs4-data/
|
--1Kints.txt
|
--2Kints.txt
|
--......
- 本实现使用
open('path')
函数作为输入,而不是使用Linux的流,因此请勿使用<
符号输入数据。可以使用如下方式运行程序:
pyalgs4$ python TopM_2.6.py 5 ./algs4-data/tinyBatch.txt
《算法》一书采Java用实现算法,但由于本人几乎不使用Java,故希望使用Python来实现这些算法。 由于本人编码水平有限,代码并没有严格Python Zen,如何疑问,欢迎提出。