Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For these two arrays of integers: array 1 : . word 9 1 , 1 5 , 7 6 7 , 8 6 1 ,

For these two arrays of integers:
array1: .word 91,15,767,861,89,21,1234
array2: .word 29,106,18,2,55,21,17,13,9999,1024,13,2,5,23,51,2021,111,89,89,91,861,1234,5004
There are some integer values that are in both of the arrays.
Write a program that uses two loops to count the integer values of array1 that are in array2. When an integer value of array1 is found to be in both arrays, place the count of the integer value in a $t register. When an integer is found to be in array1 but not in array2, place the count of the integer value as 0 in a $t register. The $t registers should have the count of integer values placed in them in the following way:
the count of the first integer value of array1 should be placed in the register $t0
the count of the second integer value of array1 should be placed in the register $t1
the count of the third integer value of array1 should be placed in the register $t2
the count of the forth integer value of array1 should be placed in the register $t3
the count of the fifth integer value of array1 should be placed in the register $t4
etc.
As an example, notice the value 91 is in both arrays. Notice also that 91 is the first integer value of array1. That means the count of 91 is 1, so 1 should be placed in the register $t0.
As another example, notice the value 15 is in array1 but not array2. Notice also that 15 is the second integer value of array1. That means the count of 15 is 0, so 0 should be placed in the register $t1.
As a third example. notice the value 89 is in both arrays. Notice also that 89 is the fifth integer value of array1. Also notice that 89 occurs two times in array2. That means the count of 89 is 2, so 2 should be placed in the register $t4.
The two loops should be arranged in a nested loop structure -- A nested loop is a loop inside another loop. The loop that is on the inside is called the inner loop. The loop that has the inner loop inside it is called the outer loop.
For this program, you are to use the outer loop to access all of the elements of array1,and use the inner loop to access all of the elements of array2.
Make sure in this program that the outer loop accesses all the elements that are in array1, and the inner loop accesses all the elements that are in array2.
As the loops run, if the inner loop accesses an element of array2 that is in array1, place the count of the array1 element into the corresponding $t register. If the inner loop does not access an element that is in array1, place the count of 0 for the array1 into the corresponding $t register.

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Why should an individual manager be interested in supporting HR?

Answered: 1 week ago