Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (20 points) Write an assembly program that implements the function below to compute n choose k, which is sometimes written as either n k

1. (20 points) Write an assembly program that implements the function below to compute n choose k, which is sometimes written as either n k or C n k . This is the number of different ways to pick a subset of size k from n things. I suggest that you take the main function that I gave you in fib.asm from lab and adapt it to call this function.

int choose(int n, int k) { if(n < k) return 0; if((n == 0) || (k == 0)) return 1; int val1 = choose(n-1, k-1); int val2 = choose(n-1, k); return val1 + val2; }

main function in lab

.text addi $v0, $zero, 5 #read integer syscall

add $a0, $v0, $zero #call fib function jal fib

add $a0, $v0, $zero #print result addi $v0, $zero, 1 syscall

addi $a0, $zero, 10 #print newline addi $v0, $zero, 11 syscall

addi $v0, $zero, 10 #exit program syscall

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

4. Who would lead the group?

Answered: 1 week ago

Question

2. What type of team would you recommend?

Answered: 1 week ago