Welcome to Westonci.ca, your one-stop destination for finding answers to all your questions. Join our expert community now! Connect with professionals on our platform to receive accurate answers to your questions quickly and efficiently. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

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.


Sagot :

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

View image lhmarianateixeira
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. We appreciate your time. Please come back anytime for the latest information and answers to your questions. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.