Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 a . Write a function combination which implements the combinatorial function n C r in MIPS assembler. A straightforward Java implementation without checks is

1a. Write a function combination which implements the combinatorial function nCr in MIPS assembler.
A straightforward Java implementation without checks is given here:
int combinations(int n, int r){
int c=1;
for(int i=r+1;in;i++
c**=i;
for(int i=1;in-r;i++)
c?=i;
return c;
}
1b. The assemble instructions for multiplication and division, respectively, are mul and div.
Use the non-recursive factorial example with loops from the class as a starting point.
Write a main function which calls combinations twice with hardcoded n and r as follows:
a.n=10,r=5(The answer is 252.)
b.n=100,r=10(The answer is 17,310,309,456,440 which takes more than 32 bits to represent!)
Exit your program with the proper syscall.
1c. Test and run your program. Provide a screenshot of test runs for the two cases.
(I haven't learned mflo or mfhi.)
Can someone help me edit my code so it can run and get the answer? When I ran the code I got the answer of 1203628800. I am trying to get the
output of 252 and 17,310,309,456,440 but the code I have is giving out an output of 330.
image text in transcribed

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions