4 ms·
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 ideall
by teddyh 9y 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?
In fact, all of these seem to be ones that are actually built into Python already.
- boomlinde 9y agoSure, but 1. someone has to implement them, and 2. they can serve an educational purpose regardless.
- JustSomeNobody 9y agoNo, it's not a design pattern. Yes it likely should be included in the language library.
- tedmiston 9y agoDoes it make sense for a language to implement all of the sorting algorithms though, especially the inefficient but simple ones like bubble sort? I would be surprised to find bubble sort in the standard library, so having this as an educational exercise makes a lot of sense to me.
- KirinDave 9y agoNot necessarily.Not all algorithms are universally applicable, nor are they universally desirable on all inputs. For example, if you have a very long (practically infinite) stream of mostly ordered items coming in and you want to semi-order a sliding window so downstream consumers have an easier time, what do you do? You can't just call Array#sort. Another example in the same vein: You get a large and mostly sorted dataset on an older 32 bit machine. It's about 500 million elements long, and loaded in memory on Python. Which sort algorithm do you use?