Question: The following algorithm computes the digits of the binary representation of a positive integer n. String of bits ConvertToBinary(int n) 1: if n ==
The following algorithm computes the digits of the binary representation of a positive integer n. String of bits ConvertToBinary(int n) 1: if n == 1 then 2: return n 3: else 4: return ((ConvertToBinary(n DIV 2)) followed by (n MOD 2)) 5: end if (a) Illustrate the execution of this algorithm to give the binary representation of 27. (b) Illustrate the execution of this algorithm to give the binary representation of 32. (c) What is the growth rate of the running time of this algorithm? (d) How could you modify the algorithm to yield hexadecimal representations?
Step by Step Solution
3.33 Rating (144 Votes )
There are 3 Steps involved in it
a Execution of the algorithm for n27 ConvertToBinary27 ConvertToBinary27 DIV 2 followed by 27 MOD 2 ... View full answer
Get step-by-step solutions from verified subject matter experts
