Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

Students also viewed these Databases questions

Question

Calculate the frequency of light that has a wavelength 520 nm.

Answered: 1 week ago

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago