Question #273644

Consider the following snippets of code. Then, identify and describe the sorting algorithm used. num scores[5] = 90,85,65,95,75 sort() x = 1 while x < SIZE temp = scores[x] y = x – 1 while y >= 0 AND scores[y]>temp scores[y+1] = scores[y] y = y – 1 endwhile scores[y+1] = temp


Expert's answer

The algorithm is bubble sort.

Bubble sort swaps the adjacent elements if the elements are in the wrong order. The swapping continues up to the last item.


LATEST TUTORIALS
APPROVED BY CLIENTS