I need to compute the time and space complexity in Big O notation for this algorithm I constructed for binary multiplication.
mul(a, b) =
- 0 if a = 0 or b = 0
- (b + p) if lowest(a) != 0
- p if lowest(a) = 0
where
p = join(mul(higher(a), b), 0)
lowest(a) returns the lowest order bit of a binary numeral a
e.g. lowest(1001101) = 1
- higher(a) returns the binary numeral excluding the lowest order bit of binary numeral a
e.g. higher(1001101) = 100110
- join(a, b) appends bit b at the end of binary numeral a
e.g. join(1101, 1) = 11011