T(n) = Θ(1) if n ≤ Kwhere a, b, d, K are constants determined by the algorithm.
T(n) = a T(n/b) + Θ(nd) otherwise
T(n) = Θ(nd) if d > logb a,
T(n) = Θ(nd log n) if d = logb a,
T(n) = Θ(nlogb a) if d < logb a.
X = xn−1 xn−2 ... x1 x0
Y = yn−1 yn−2 ... y1 y0
X = 2n/2 X1 + X0where multiplication by a power of 2 indicates shifting of bits.
Y = 2n/2 Y1 + Y0
X Y = 2n X1 Y1 + 2n/2 (X0 Y1 + X1 Y0) + X0 Y0
multiply(X, Y): if n == 1: return x * y # multiplication of 1-bit integers else: set lists X1, X0, Y1, Y0 as above p1 = multiply(X1, Y1) p2 = multiply(X1, Y0) p3 = multiply(X0, Y1) p4 = multiply(X0, Y0) return 2**n * p1 + 2**(n/2) * (p2 + p3) + p4