Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2.6 The table below shows 32-bit values of an array stored in memory For the mem

ID: 3756111 • Letter: 2

Question

2.6 The table below shows 32-bit values of an array stored in memory For the memory locations in the table below, write pseudocode to move the array locations around so that they are sorted lowest to highest. Use temporary variable names Temp1, Temp2, Temp3, etc. as needed. Don't try to write in MIPS assembly, write in C, for example: At 1 ] 2 ] or Tempi- A[1) orATempl. a. Assume that this particular machine uses byte-addressable RAM and a word size of four bytes exactly as we have discussed in class. Complete the table below first and then write code to implement the final column Array Byte Present Valuc New From Array Value &32 Page 1 of 7 COSC 2440-Computer Organization and Architecture A3 &36

Explanation / Answer

Array Index

Byte Address

Present Value

New Value

From Array Index

A[0]

&24

8

5

&28

A[1]

&28

5

4

&32

A[2]

&32

4

2

&36

A[3]

&36

2

7

&40

A[4]

&40

7

8

&24

#include<stdio.h>

void printArray(int ar[],int n)

{

int i;

for(i=0;i<n;i++)

{

printf("%d ",ar[i]);

}

printf(" ");

}

int main()

{

int i,j,n=5;

int ar[] = {8,5,4,2,7};

int temp;

for(i=0;i<n;i++)

{

for(j=0;j<n-i-1;j++)

{

if(ar[j]>ar[j+1])

{

temp = ar[j];

ar[j] = ar[j+1];

ar[j+1] = temp;

}

}

printf("After %d Iteration ",i+1);

printArray(ar,n);

}

return 0;

}

Array Index

Byte Address

Present Value

New Value

From Array Index

A[0]

&24

8

5

&28

A[1]

&28

5

4

&32

A[2]

&32

4

2

&36

A[3]

&36

2

7

&40

A[4]

&40

7

8

&24