0

Design and analyze an algorithm to multiply 2 numbers A and B, each n bits longs, but partitioning them into 3 equal sized pieces each and using the Strassen's algorithm. What is the best running time you can get?

I have two numbers that are n length and separated them into three equal parts. For example, 123 separates into 1, 2, and 3. From my understanding, I have to use matrices. However, Strassen's algorithm does not make any sense to me.

I have watched videos and read lectures but still have no clue on how to proceed. Any help would be appreciated, thank you!

o.o
  • 3,563
  • 9
  • 42
  • 71
  • 1
    What sources did you try using? What exactly do you need help understanding? – Joni Feb 17 '16 at 20:47
  • I looked on YouTube for videos on stassens algorithm and its explanation but I not sure if i am approaching the question correctly. I have two numbers of length N. and I need to split them up into 3 equal parts. does this mean i will be making three different matrices. How would this number ultimately equal the result and how (IF i am thinking about it correctly) are these 3 parts seperated – o.o Feb 17 '16 at 20:49
  • Schonhage-Strassen integer multiplication algorithm doesn't divide the input into blocks. Maybe you were asked to implement Toom-Cook? https://en.m.wikipedia.org/wiki/Toom–Cook_multiplication – Joni Feb 17 '16 at 21:00
  • It says Strassen in here: http://i.imgur.com/20yLNJi.png. – o.o Feb 17 '16 at 21:04
  • Agree with Joni. It makes more sense if it's Toom-Cook. Otherwise, it could be Schönhage–Strassen that you are asked to use, but with radix `3` FFT. See https://en.wikipedia.org/wiki/Sch%C3%B6nhage%E2%80%93Strassen_algorithm – WhatsUp Feb 17 '16 at 21:33
  • 2
    I think I see it now. You're supposed to use the idea behind Strassen's matrix multiplication algorithm to implement integer multiplication: figure out a way to compute the product using fewer than 9 products of n/3-bit numbers. Nothing to do with matrixes. – Joni Feb 17 '16 at 21:39
  • I'm sorry, I don't understand what you mean. – o.o Feb 17 '16 at 22:57
  • @Joni your interpretation makes sense. Yet the question is fishy at best because it has several plausible interpretations. Not OP's fault of course – Niklas B. Feb 17 '16 at 23:58

1 Answers1

1

Since this is homework, I'll give just a hint at first:

Dividing two n-bit numbers into three blocks means representing them as X = x_0 + x_1 b + x_2 b^2 and Y = y_0 + y_1 b + y_2 b^2 where b is a base, for example b = 2^(n/3). Compute their product XY. It will be a 4-degree polynomial in base b.

The coefficients of this polynomial can be computed with addition and subtraction from these 6 products:

x_0 y_0
x_1 y_1
x_2 y_2
(x_0 + x_1)(y_0 + y_1)
(x_0 + x_2)(y_0 + y_2)
(x_1 + x_2)(y_1 + y_2)

This way the work of computing the product of XY has been reduced from computing 9 products of n/3 bit numbers to only 6, making it faster than the O(n^2) method taught in school.

Joni
  • 108,737
  • 14
  • 143
  • 193