Skip to content

Instantly share code, notes, and snippets.

@rgardner
Last active August 29, 2015 14:07
Show Gist options
  • Save rgardner/a8e0863ac7b806678eb0 to your computer and use it in GitHub Desktop.
Save rgardner/a8e0863ac7b806678eb0 to your computer and use it in GitHub Desktop.
def array_multiply(a):
    if len(a) == 2:
        return mul(a[0], a[1])
    else:
        return mul(array_multiply(a[0:len(a)/2], a[len(a)/2:len(a)]

Is that what you guys did? He said the algorithm was simple and to me this seems to work. I’m having a tough time with the tree though:

r = 8, l = 4

      285405120          |    O(14^a)
   8712      32760       |    O(7^a) + O(8^a)
 72  121   156   210     |  4 O(8^a)   
8 9 10 11 12 13 14 15    |

I can’t seem to get the time complexity to work, unless my exponent algebra is wonky.

I’m going to keep working on it, but I’m about to get on a flight back to NY, so I won’t have Internet until 12:30...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment