Question: 1 Number Representation (20 points) (Learning Objective 2) The following function prints a given unsigned long integer n to the stdout in a specified number

 1 Number Representation (20 points) (Learning Objective 2) The following function

prints a given unsigned long integer n to the stdout in a

specified number base (radix r). The radix r may be any integer

1 Number Representation (20 points) (Learning Objective 2) The following function prints a given unsigned long integer n to the stdout in a specified number base (radix r). The radix r may be any integer between 2 and 10 (inclusive). For a radix r, the valid symbols are 0 through r-1 inclusive). For a symbol of value in [0 9, is printed as a character in '0', ..., '9accordingly. 1 / express an unsigned number n using symbols for a radix r, 2 // where 20 // update n and weight for unsigned long weight 1; 10 while ((n / weight ) >= r) { // while n/r"k >= r 12 13 hile (weight > 0) 15 17 veight eight * r; fputc '0' + (n / veight), atdout); 11 print symbol n n % weight; veighteight /r; positions k-1 to o (a) (4 points) If n is 33, write down the respective values of weight in the form of r for different values of r when the while-loop in lines 10-12 terminates. For exape, or 50 is of the expected format. . n is 33, r is 2: weight is . n is 33, r is 5: weight is (b) (4 points) Write down in terms of n and r the number of times the following statements are executed: Line 9 Line 10: Line 11: Line 13: e 4 points) Write down in terms of n and r the time complexity and space complexity of the implemerntation priat inasigned.long Jusiry your answer Time complexity: Space complexity: (d) (4 points) The following function is a recursive implementation to print a given unsigned long integer n to the stdout in a specified number base (radix r). 19 void rec-print unsigned long (unaigned long n, unaigned int r) 20 t 21 if (n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets go through each part one by one a Values of weight for Different Values of r when n is 33 To fi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!