News for hackers. Stuff that matters.
Re:Algorithms Implemented in Python by lorenzhs on Sunday September 23, 2018 @07:41AM (#18050615)
This collection is bad. I had a look at several implementations and pretty much everything I looked at was bad, and not in a subtle way. It may well be that some of things in there are good, but given the amount of bad, you really shouldn't use this for learning.

Here's a short list of things I found that were really bad, all of which we teach our first-year students how to do correctly:

- the entire `Graphs/` directory is a dumpster fire. The implementation of Dijkstra's algorithm doesn't use a priority queue, nor does that of Prim's MST algorithm. Both of these also use a strange hard-coded maximum distance of 100000 for no reason. Both Kruskal implementations are bad, too: one doesn't use any kind of Union-Find data structure, the other uses a naive version which has terrible worst case behaviour.

- There is another implementation of Dijkstra's algorithm in `data_structures/Graph/dijkstra.py` that is just as bad.

- The DFS implementation in `data_structures/Graph/DepthFirstSearch.py` isn't a DFS.

- The sorting and selection algorithms are comically bad, too. `sorts/merge_sort_fastest.py` really takes the cake here. It is neither a mergesort nor fast (it's a weird non-inplace implementation of cocktail shaker sort, with quadratic best- and worst-case behaviour). The quicksort at `sorts/quick_sort.py` always uses the first element as a pivot, which is a bad idea. Its partitioning also copies the entire data in every recursive step, which is an even worse idea. The quickselect in `searches/quick_select.py` at least uses a random pivot, but also partitions out-of-place.

- Why does this contain an implementation of FTP?

Re:Algorithms Implemented in Python by jsnell on Sunday September 23, 2018 @09:44AM (#18051046)
So the repository is billed as "Open Source Resource for Newbies to Learn Algorithms and Implement them in any Programming Language". Which I would indeed have interpreted as a resource for learning, but it actually seems to be meant as "newbies implementing algorithms while learning from some other source, and submitting the results to this repository".
Re:Algorithms Implemented in Python by copperx on Sunday September 23, 2018 @01:45PM (#18052177)
I'm thinking a "roast my algorithm" forum or subreddit would be amusing.
Re:Algorithms Implemented in Python by bquinlan on Sunday September 23, 2018 @09:07AM (#18050911)
Also, the space and time complexity analysis is incorrect for Trie: https://github.com/TheAlgorithms/Python/blob/master/data_str...
Re:Algorithms Implemented in Python by doomjunky on Sunday September 23, 2018 @09:52PM (#18054487)
Actually it's a good didactical way to first implement the "raw" version of Dijkstra's algorithm without a priority queue and than discuss the other variants of the algorithm afterwards, because priority queues are another topic that adds extra difficulty and doesn't yield any benefit to comprehend the acutal problem.
Re:Algorithms Implemented in Python by matrixagent on Sunday September 23, 2018 @08:33AM (#18050795)
Thanks for your warning! I'd love something like this with good implementations (and documentation as to why the implementation is good), does anyone know similar projects?
Re:Algorithms Implemented in Python by js2 on Sunday September 23, 2018 @10:25AM (#18051194)
Re:Algorithms Implemented in Python by lazarljubenovic on Sunday September 23, 2018 @10:51AM (#18051302)
Do you happen to know of a TypeScript/JavaScript equivalent?
Re:Algorithms Implemented in Python by js2 on Sunday September 23, 2018 @07:27PM (#18053918)
Re:Algorithms Implemented in Python by emredjan on Sunday September 23, 2018 @08:56AM (#18050875)
Not a github repo, but a pretty good book if you want to see how these structures and algorithms are implemented in python: https://www.oreilly.com/library/view/data-structures-and/978...
Re:Algorithms Implemented in Python by tomrod on Sunday September 23, 2018 @09:33AM (#18050991)
Is it worth submitting pull requests to fix?