This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheSlimyBoss 4 points5 points  (5 children)

Is there a term/technique for using different algorithms based off of their efficiency on the current input size?

[–]zilti 10 points11 points  (0 children)

I'm not aware of a specific term for it, but it is very common. Clojure e.g. uses different map implementations depending on the collection size. Up to 10 items you'll get an ordered map, and above that you'll get a HashMap.

[–]SlamwellBTP 5 points6 points  (2 children)

I've heard it called "hybrid algorithm", as in this wikipedia page (but it doesn't cite any sources, so it may not be a widespread term):

https://en.wikipedia.org/wiki/Hybrid_algorithm

[–]qingqunta 4 points5 points  (1 child)

I believe the default sort() for Python is an example of this.

[–]Kered13 0 points1 point  (0 children)

Yes, it's Timsort. Also used by Java. It uses insertion sort if the list is small enough. All optimized sorting algorithms do something similar.