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

What aigorithm does the following pseudocode perform? Declare Integer maxElement

ID: 3741407 • Letter: W

Question

What aigorithm does the following pseudocode perform? Declare Integer maxElement Declare Integer index For maxElement arraysize 1 To 0 Step -1 For index = 0 To maxElement - 1 If array[index] > array[index1] Then Call swap(array[index], array[index 1) End If End For End For 3. What algorithm does the following pseudocode perform? Declare Integer index Declare Integer scan Declare Integer unsortedValue For index = 1 To arraysize - 1 Set unsortedValue = array [index] set scan = index While scan >0 AND array[scan-1]

Explanation / Answer

Ans2 . This pseudocode perform the algorithm of Bubble sort to sort an array of integers. It loops through each element except for last element of the array, compares it to the next element, and if next element is smaller then swaps the two integers else leave them as it is.In the end of this procedure , the list/ array is sorted in ascending order (smaller first, larger next)

Ans3 . This pseudocode perform the algorithm of Selection sort to sort an array of integers. It selects one initial position, then loops through each element except for last element of the array, untill it finds a value smaller than value on its own location. If it finds a value smaller than at its own then it swaps the two values and moves to next position and again checks in similar way. In the end of this procedure , the list/ array is sorted in ascending order (smaller first, larger next).

NOTE: If you want code and code output kindly leave comment. If you got what you wanted please give this answer a thumbs up.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote