Answered step by step
Verified Expert Solution
Question
1 Approved Answer
note the following error in the algorithm in HW#:Q . 1 . Consider the following pseudocode for the selection sort algorithm and answer the questions
note the following error in the algorithm in HW#:Q Consider the following pseudocode for the selection sort algorithm and answer the questions below.
Algorithm : Selection Sort.
Input Variables:
: size of array of integers
A: array of integers
Temporary Variables:
minj: index of current minimum number
temp: value of current minimum number
: Looparray indexing variables.
for ilarr to do
minjlarri
for jlarri to do
if minjlarrjminjilarrA then
minjlarrj
minji then
temp larrA
temp
a Write an ARM assembly code for the selection sort Algorithm Assume A and are both variables stored in memory. Assume the array is defined as volatile.
b Simulate the program you have written using VisUAL ARM emulator with an input array Include a snapshot to show that your program produced the correct output. Make sure to include both registers and memory view in your snapshots. Use the "View Memory Content" to show the sorted array.
c Consider a modified version of the algorithm called Algorithm In this version, the search for the index of the minimum number is performed by a function call. Repeat Part a using Algorithm You may need to add instructions before and after the function call to do what is necessary to perform the function call. Use the stack to preserve and restore all needed registers before and after the function call.
Algorithm : Selection Sort.
Input Variables:
: size of array of integers
: array of integers
Temporary Variables:
minj: index of current minimum number
temp: value of current minimum number
: Looparray indexing variables.
for ilarr to do
minjfindMIN
if minji then
temp larrA
temp
int fundMINint int int:
minjlarri
for jlarri to do
if minjlarrjA then
minjlarrj
return minj
Incorrect::
if Aj Ai then
Correct::
if Aj Aminj then
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