I have few Python algorithms and data structures here:
<a href="https://github.com/lion137/Python-Algorithms" rel="nofollow">https://github.com/lion137/Python-Algorithms</a>
<a href="https://github.com/lion137/Python-Data-Structures" rel="nofollow">https://github.com/lion137/Python-Data-Structures</a>
You can use them if you want to extend a bit your; all tested and working (as far as I know).
Let me know if you need me to add any comments/explanations to code...
In the binary search algorithm :<p>mid = (left + right) // 2<p>It would be nice to have a discussion on why you used // instead of /. Depending on who reads your code, explaining this "obvious" choice might be interesting.<p>There are also other discussions topic : what happens if the array is empty ? what happens if the array is twice the size of the computer's RAM ? What happens if all the numbers in the array are equal ?
If something is a “major” algorithm, isn’t this just like a “Design Pattern”, in that it really is something which should be built into the language, and ideally isn’t something you should implement yourself?<p>In fact, all of these seem to be ones that are actually built into Python already.
Here is a fun one-liner quicksort in Python:<p>def q(list): return [] if list==[] else q([x for x in list[1:] if x < list[0]]) + [list[0]] + q([x for x in list[1:] if x >= list[0]])
This is a neat learning tool. Will recommend to those starting out. A couple of suggestions if you have the time or will try to send a pull (!) ..
1) A built in dataset (numbers, chars, wordlist)
2) a single step mode
This is great! If I could make a suggestion it would be to add the space complexity of each algorithm to the comments(the time complexity is already there.)
Once upon a time I made a Github repo with the same name and intention <a href="https://github.com/ssijak/pygoritm" rel="nofollow">https://github.com/ssijak/pygoritm</a><p>It is sitting there alone... abandoned... Sorry poor repo that I never made something big from you. You deserve much more stars (p.s. don't tell him that the only one is from me) :(