TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Pygorithm – A Python module for learning major algorithms

191 pointsby PleaseHelpMealmost 8 years ago

8 comments

tu7001almost 8 years ago
I have few Python algorithms and data structures here: <a href="https:&#x2F;&#x2F;github.com&#x2F;lion137&#x2F;Python-Algorithms" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lion137&#x2F;Python-Algorithms</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;lion137&#x2F;Python-Data-Structures" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lion137&#x2F;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&#x2F;explanations to code...
wiz21calmost 8 years ago
In the binary search algorithm :<p>mid = (left + right) &#x2F;&#x2F; 2<p>It would be nice to have a discussion on why you used &#x2F;&#x2F; instead of &#x2F;. Depending on who reads your code, explaining this &quot;obvious&quot; 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&#x27;s RAM ? What happens if all the numbers in the array are equal ?
评论 #14958507 未加载
teddyhalmost 8 years ago
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.
评论 #14957462 未加载
评论 #14958760 未加载
评论 #14958417 未加载
评论 #14957386 未加载
wooptooalmost 8 years ago
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 &lt; list[0]]) + [list[0]] + q([x for x in list[1:] if x &gt;= list[0]])
评论 #14956316 未加载
评论 #14956195 未加载
thesmallestcatalmost 8 years ago
What is a &quot;major&quot; algorithm? This repo is pretty light, so the bar must be high.
评论 #14957640 未加载
hakcermanialmost 8 years ago
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
bogomipzalmost 8 years ago
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.)
ssijakalmost 8 years ago
Once upon a time I made a Github repo with the same name and intention <a href="https:&#x2F;&#x2F;github.com&#x2F;ssijak&#x2F;pygoritm" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ssijak&#x2F;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&#x27;t tell him that the only one is from me) :(