Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer correctly as it is a very important assignment You are going to write a MIPS program that does the following (there is C++

Please answer correctly as it is a very important assignment

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 21 INTEGERS, you can put whatever you want in it, but they shouldnt be sorted. Without using recursion:
    1. Create a procedure to find the largest called findLargest
    2. Create a procedure to find the smallest called findSmallest.
    3. 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-maximum-elements-of-array/ has an example of this in several higher level languages).

Testing

In your testing (below or an attached document), provide a brief description of what is being tested, followed by a screen capture showing that the code works. Include your testing document with your source code in the zip file.

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

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Explain the stages in the negotiating process.

Answered: 1 week ago