Mercurial > algorithms
changeset 2:2a6239659909
Expanded comments in two_sum.pl
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Fri, 01 May 2015 12:17:52 -0500 |
parents | b71457723bed |
children | 5b53a317106c |
files | two_sum/two_sum.pl |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/two_sum/two_sum.pl Fri May 01 12:12:07 2015 -0500 1.2 +++ b/two_sum/two_sum.pl Fri May 01 12:17:52 2015 -0500 1.3 @@ -16,6 +16,11 @@ 1.4 # the two numbers (along with their indices). Otherwise we add num to the hash 1.5 # and loop back to read the next input number. 1.6 1.7 +# Overall performance is O(N) in the worst case, since in that case we must 1.8 +# process each input item exactly once. (For each item, we perform one lookup 1.9 +# into the hash, which adds only a small constant to the running time per 1.10 +# iteration of the loop.) 1.11 + 1.12 # Usage: Pass the target value as a command line option, and the number array as 1.13 # values on stdin, one item per line. 1.14