4 ms·
If small-bound is <20 and likely to never be >50, yes. Otherwise, be careful; future people will not thank you for that timebomb.
by dehrmann 5y ago
If small-bound is <20 and likely to never be >50, yes. Otherwise, be careful; future people will not thank you for that timebomb.
- jedberg 5y agoIf you're really cool, you make it throw an error if n > 50 along with a comment explaining why, or at the very least leave a comment saying "this is not the optimal algorithm and will break if N gets much bigger than 50".
- travisjungroth 5y agoIt’s safer when it’s hard coded data and really bad versus dynamic data and sorta bad. I’d rather have O(n!) with a list of length six because it’s going to break hard before it gets to 20. O(n root(n)) on your customer list will slowly creep up and it would be easy to not notice.