Question
What algorithm does this code perform please help out ASAP. You can add code and output but I really need what algorithm it is performing
4. What algorithm does the following pseudocode perform? Declare Integer startscan Declare Integer minIndex Declare Integer minValue Declare Integer index For startScan = 0 To arraysize - 2 set minindex = startscan Set minValue = array [startscan] For index startscan 1 To arraySize 1 If array[index] < minValue Set minValue array [index] Set minIndex-index End If End For call swap(array[minIndex], arraylstartScan]) End For
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The algorithm is sorting the array in ascending order using selection sort technique as below:-

  • In the first iteration it is finding the minimum value in the entire array and swapping this minimum value with the first value of the array
  • In the second iteration it is finding the minimum value from second position to last position of the array and swapping this minimum value with second element of the array
  • likewise for remaining iterations it is finding the minimum value from remaining array and swapping it with the first element of the remaining array
Add a comment
Know the answer?
Add Answer to:
What algorithm does this code perform please help out ASAP. You can add code and output...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT