Question 7
1 pts
A general algorithm for constructing a base b
expansion of a number n is given by
ALGORITHM 1 Constructing Base b Expansions.
procedure base b expansion(n, b: positive integers with b > 1)
q := n
k := 0
while q ? 0
ak := q mod b
q := q div b
k := k + 1
return \((a_{k-1},..., a_1, a_0)\) \{\((a_{k-1}...a_1a_0)\) is the base b expansion of n\}
What is the big O complexity of this algorithm?
O(\log_b n\) \{log n with base b\}
O(n)
O (n b)
O(b)