Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Raspberry Pi / ARM) Computer Organization & Assembly Language Programming : In this assignment, you will implement a recursive solution for computing the number of

(Raspberry Pi / ARM) Computer Organization & Assembly Language Programming :

In this assignment, you will implement a recursive solution for computing the number of integer partitions of a positive integer n

with parts up to m. In number theory, a n integer partition is a way of writing n as a sum of positive integers (in this case, positive integers up to

m). For example, the partitions for n = 5 and m = 3 are:

5 = 1 + 1 + 1 + 1 + 1

5 = 2 + 1 + 1 + 1

5 = 2 + 2 + 1

5 = 3 + 1 + 1

5 = 3 + 2

Thus, there are 5 integer partitions for n = 5 and m = 3. This problem can be solved recursively using the following function:

int count_partitions(int n, int m)

{

if (n == 0)

return 1;

else if(n < 0)

return 0;

else if (m == 0)

return 0;

else

return count_partitions(n - m, m) + count_partitions(n, m - 1);

}

Your main function will contain a loop that continuously checks for keyboard input in the

following pattern:

Once the 2 lines of input are acquired, the operands should be loaded into the proper registers

and the count_partitions procedure should be called. The procedure should return the result in register R0, and

the main function should print there are x partitions of n using integers up to m and skip to a new line.

All input test cases will consist of positive numbers only, and OPERAND_M will always be less than or equal to OPERAND_N.

Below is how the input/output should look for the example above:

5

3

There are 5 partitions of 5 using integers up to 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions