Question: You are going to write a MIPS program that does the following (there is C++ sample code below to explain the logic): 1) Create an

You are going to write a MIPS program that does the following (there is C++ sample code below to explain the logic): 1) Create an array of 16 INTEGERS, you can put whatever you want in it, but they shouldnt be sorted. Without using recursion: a. Create a procedure to find the largest called findLargest b. Create a procedure to find the smallest called findSmallest. c. Create procedure called range, which is the difference between largest and smallest (range should call findLargest and findSmallest)

2) Create a recursive procedure to find the largest (call it findLargestRecursive) (https://www.geeksforgeeks.org/recursive-programs-to-find-minimum-and-maximumelements-of-array/ has an example of this in several higher level languages). So something like this C++code, except you need to write it in MIPS. #include "pch.h" //Theres no equivalent to this in MIPS so ignore it #include //theres no equivalent to this either.

int theArray[] = { 5, 7, 1, 4, 9, 11, 15, 0, -1 }; int findLargest() { int temp = theArray[0]; for (int i = 0; i < 10; i++) if (temp < theArray[i]) temp = theArray[i]; return temp; } int findSmallest() { int temp = theArray[0]; for (int i = 0; i < 10; i++) if (temp > theArray[i]) temp = theArray[i]; return temp; } int findRange() { return findLargest() - findSmallest(); } int main() { std::cout << findLargest() << std::endl; std::cout << findSmallest() << std::endl; std::cout << findRange() << std::endl; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!