1,2,3,4,5,6,7,8,9,10 – Best case - Sorted in ascending order
10,9,8,7,6,5,4,3,2,1 – Worst case - Sorted in reverse order
1,3,2,5,4,7,9 ,6,8,10 – Avg case – numbers are in random order

For the given numbers, please use the following algorithms (bubble sort, insertion sort & selection
sort) to sort in ascending order. Please also find out number of comparisons and data movements
for each algorithm. Based on comparisons and data movements please rate algorithm for each input
case.

Respuesta :

Using the knowledge in computational language in python it is possible to write a code that from a random number draw creates an order of increasing numbers

Writting the code in python:

def shellSort(array, n):

   # Rearrange elements at each n/2, n/4, n/8, ... intervals

   interval = n // 2

   while interval > 0:

       for i in range(interval, n):

           temp = array[i]

           j = i

           while j >= interval and array[j - interval] > temp:

               array[j] = array[j - interval]

               j -= interval

           array[j] = temp

       interval //= 2

data = [10,9,8,7,6,5,4,3,2,1]

size = len(data)

shellSort(data, size)

print('Sorted Array in Ascending Order:')

print(data)

See more about python at brainly.com/question/18502436

#SPJ1

Ver imagen lhmarianateixeira