|
|
|
|
|
by someplaceguy
697 days ago
|
|
I found this part of the code quite funny: # If there are < 5 items, just return the median
if len(l) < 5:
# In this case, we fall back on the first median function we wrote.
# Since we only run this on a list of 5 or fewer items, it doesn't
# depend on the length of the input and can be considered constant
# time.
return nlogn_median(l)
Hell, why not just use 2^140 instead of 5 as the cut-off point, then? This way you'd have constant time median finding for all arrays that can be represented in any real-world computer! :) [1][1] According to https://hbfs.wordpress.com/2009/02/10/to-boil-the-oceans/ |
|
Any halting program that runs on a real world computer is O(1), by definition.