Question
Write an ARMv8 program to sort an array of elements. As I mentioned in class, this problem uses a portion of your Programming Assignment 1
Write an ARMv8 program to sort an array of elements. As I mentioned in class, this problem uses a portion of your Programming Assignment 1 where you computed the smallest and largest values in an array. Here we will extend that assignment to find the index of the smallest and the index of the largest elements of the array. The following C code segment illustrates how we can sort the element of an array.
For this problem, assume an array with 8 elements and test your code with the array initialized to 17, 12, 3, 7, 31, 27, 5, 19 Submit: A file containing your ARMv8 code, a read me file (if needed), a snapshot of memory showing the values in the array before your program starts execution and a snapshot of memory showing the values in the array after the program completes execution. Optional: You can include additional snapshots to show how you are using Stack, or snapshots of the array elements in between the original values and final sorted values.
You can also test and show results with different array sizes and values.
i =0;
while (i < n)
{
find_smallest (&a, i, n, index); /*returns the index of next smallest element
swap (&a, i, index); /* swap smallest with a[i]
find_largest (&a, i, n, index); /* returns the index of next largest element
swap (&v, n, index); /* swap largest with a[n]
i = i+1;
n = n-1;
}
The three functions called by above C segments are shown next.
void find_smallest (long long int *a, long long int i, long long int n, long long int index)
{
long long int smallest = a[i];
index = i;
for (j = i; j largest)
{
largest = a[j];
index = j;
}
void swap (long long int *a, long long int i, long long int j)
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started