void swap (int arr[], int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] } temp; void selectionSort (int arr[], int n) { for (int i = 0; i < n 1; i++) { int min i; for (int j=i+1; j < n; j++) { if (arr[j] arr[min]) min = j; swap (arr, min, i); } } } int main() { int arr[] = { 3, 5, 8, 4, 1, 9, -2 }; int n = 7; selectionSort (arr, n); return 0; } 1. Tranlaste the above C program to MIPS codes, suppose the starting address of codes is binary number 1000, the starting address of data is binary number 100000. 2. Translate the first MIPS codes of "if (arr[j]

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter14: Exploring Object-based Programming: Designing An Online Poker
Section14.1: Visual Overview: Custom Objects, Properties, And Methods
Problem 7QC
icon
Related questions
Question
Please help me with questions 1 and 2
void swap (int arr[], int i, int j)
{
int temp = arr[i];
arr[i] = arr[j];
arr[j]
}
temp;
void selectionSort (int arr[], int n)
{
for (int i = 0; i < n 1; i++) {
int min i;
for (int j=i+1; j < n; j++) {
if (arr[j] arr[min])
min = j;
swap (arr, min, i);
}
}
}
int main()
{
int arr[] = { 3, 5, 8, 4, 1, 9, -2 };
int n = 7;
selectionSort (arr, n);
return 0;
}
1. Tranlaste the above C program to MIPS codes, suppose the starting address of codes is binary
number 1000, the starting address of data is binary number 100000.
2. Translate the first MIPS codes of "if (arr[j] <arr [min]) min j;" to Machine lan-
guage codes
3. Run the above machine codes at the first time on Figure 4.17, refer to Figure 4.19, 4.20, 4.21,
4.24. Label the values on all the input and output lines in the following datapath diagram.
2
Transcribed Image Text:void swap (int arr[], int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] } temp; void selectionSort (int arr[], int n) { for (int i = 0; i < n 1; i++) { int min i; for (int j=i+1; j < n; j++) { if (arr[j] arr[min]) min = j; swap (arr, min, i); } } } int main() { int arr[] = { 3, 5, 8, 4, 1, 9, -2 }; int n = 7; selectionSort (arr, n); return 0; } 1. Tranlaste the above C program to MIPS codes, suppose the starting address of codes is binary number 1000, the starting address of data is binary number 100000. 2. Translate the first MIPS codes of "if (arr[j] <arr [min]) min j;" to Machine lan- guage codes 3. Run the above machine codes at the first time on Figure 4.17, refer to Figure 4.19, 4.20, 4.21, 4.24. Label the values on all the input and output lines in the following datapath diagram. 2
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning