Show that Algorithm 4 uses O(qloga) bit operations, as-
suming that a>d.
ALGORITHM 4 Computing div and mod.
procedure division algorithm( a : integer, d : positive integer)
q:=0
r:=|a|
while r>=d
r:=r-d
q:=q+1
if a<0 and r>0 then
r:=d-r
q:=-(q+1)
return is the quotient, r=amodd is the remainder
ALGORITHM 4 Computing div and mod.
procedure division algorithm(a: integer, d: positive integer) q:=0 1p|=:u while r > d r=r-d q=q+1 if a < 0 and r > 0 then r:=d-r q := -(q+1) return (q, r) {q = a div d is the quotient, r = a mod d is the remainder}