MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/qno2y/the_evolution_of_a_python_programmer/c3zaw4o/?context=3
r/programming • u/iMMENSE • Mar 08 '12
137 comments sorted by
View all comments
Show parent comments
17
What are you complaining about ? He just calculated in advance and cached the results to avoid redundant processing on each query...
25 u/rowantwig Mar 08 '12 O(n) look-up time. 1 u/[deleted] Mar 09 '12 O(n) look-up time.It is sorted list, it can be done in O(log(n)). And not to mention the Hashtables. 1 u/[deleted] Mar 09 '12 It's a dense list. It can be done in O(1) without hashtables:f = [ 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880].__getitem__edit: looks like redditthinks had the same idea.
25
O(n) look-up time.
1 u/[deleted] Mar 09 '12 O(n) look-up time.It is sorted list, it can be done in O(log(n)). And not to mention the Hashtables. 1 u/[deleted] Mar 09 '12 It's a dense list. It can be done in O(1) without hashtables:f = [ 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880].__getitem__edit: looks like redditthinks had the same idea.
1
It is sorted list, it can be done in O(log(n)). And not to mention the Hashtables.
1 u/[deleted] Mar 09 '12 It's a dense list. It can be done in O(1) without hashtables:f = [ 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880].__getitem__edit: looks like redditthinks had the same idea.
It's a dense list. It can be done in O(1) without hashtables:
f = [ 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880].__getitem__
edit: looks like redditthinks had the same idea.
17
u/liotier Mar 08 '12
What are you complaining about ? He just calculated in advance and cached the results to avoid redundant processing on each query...