To sort a list of 15 values using a bubble sort the greatest

To sort a list of 15 values using a bubble sort, the greatest number of times you would have to pass through the list making comparisons is _____.

a. 12

b.13

c.14

d.15

Solution

The bubble sort algorithm works by finding the minimum element in the list of 15 values, keeping it at the starting index then repeating the step from 2nd index value.

The number of iterations will be (15-1) = 14

Since after 14 iterations, the list will be completely sorted after inserting 14th element, the last element will also be in the correct position

To sort a list of 15 values using a bubble sort, the greatest number of times you would have to pass through the list making comparisons is _____. a. 12 b.13 c.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site