<jupyter_start><jupyter_text>CREATE A LIST OF ARRAY SIZES<jupyter_code>ARRAY SIZE = [100, 250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500,3750, 5000, 6250,  7500, 8750, 10000]<jupyter_output><empty_output><jupyter_text>CREATE A RANDOM ARRAY<jupyter_code>#Genarate random numbers
from random import randint
def random_array(n):
    array = []
    for i in range (0, 100, 1): #between 0 and 100
        array.append(randint(0,100))# 100 random integers
    return array<jupyter_output><empty_output><jupyter_text>BUBBLE SORT<jupyter_code># Credit https://www.geeksforgeeks.org/bubble-sort/
# Python program for implementation of Bubble Sort 

def Bubble_Sort(array): #bubble sort function
    n = len(arr) #assign n = to length of the array
  
    # Iterate through all array elements 
    for i in range(n): 
  
    # Last i elements are already in place 
        for j in range(0, n-i-1): 
  
        # iterate through the array from 0 to n-i-1 
        # Swap if the element found is greater 
        # than the next element 
            if arr[j] > arr[j+1] : 
                arr[j], arr[j+1] = arr[j+1], arr[j] 
  
Bubble_Sort(arr) 
  
print ("Sorted array is:") 
for i in range(len(arr)): 
    print ("%d" %arr[i]),<jupyter_output><empty_output><jupyter_text>BUCKET SORT<jupyter_code>#Credit https://www.geeksforgeeks.org/bucket-sort-2/
# Python3 program to sort an array  
# using bucket sort  
def Insertion_Sort(b): #function to create an insertion - needed to sort data once its in buckets
    for i in range(1, len(b)): #iterate through all the data
        up = b[i] 
        j = i - 1
        while j >=0 and b[j] > up:
            b[j + 1] = b[j] 
            j -= 1
        b[j + 1] = up     
    return b      
              
def Bucket_Sort(x): #create buckets
    arr = [] #empty array
    slot_num = 10 # 10 means 10 slots, each 
                  # slot's size is 0.1 
    for i in range(slot_num): #for each slot number
        arr.append([]) #append slot numbers to the array
          
    # Put array elements in different buckets  
    for j in x: 
        index_b = int(slot_num * j)  
        arr[index_b].append(j) 
      
    # Sort individual buckets  using the insertion sort created earlier
    for i in range(slot_num): 
        arr[i] = Insertion_Sort(arr[i]) 
          
    # concatenate the result 
    k = 0
    for i in range(slot_num): #for each sorted bucket, add them together
        for j in range(len(arr[i])): 
            x[k] = arr[i][j] 
            k += 1
    return x 
  
# Driver Code 
x = [0.897, 0.565, 0.656, 
     0.1234, 0.665, 0.3434]  
print("Sorted Array is") 
print(Bucket_Sort(x)) 

# This code is contributed by 
# <NAME><jupyter_output>Sorted Array is
[0.1234, 0.3434, 0.565, 0.656, 0.665, 0.897]<jupyter_text>COUNTING SORT<jupyter_code># Credit https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-search-and-sorting-exercise-10.php
def Counting_Sort(array1, max_val): # function for counting sort, takes an array and a max value
    m = max_val + 1 #assigns m as max value +1: needed to create index for count sub-array 'count'
    count = [0] * m  #sub array to hold the counts for each element of the array              
    
    for a in array1: #loop which iterates through each item in the array
    
        count[a] += 1 # count occurences of each element             
    i = 0
    for a in range(m): #Outer sorting loop to iterate through count sub-array           
        for c in range(count[a]):  #inner sorting loop which iterates through the counts of each element
            array1[i] = a #sorts elements by swapping count items
            i += 1 #increases position of count item to be sorted 
    return array1

print(Counting_Sort( [1, 2, 7, 3, 2, 1, 4, 2, 3, 2, 1], 7 ))<jupyter_output>[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 7]<jupyter_text>MERGE SORT<jupyter_code>#Credit This code is contributed by <NAME> @ https://www.geeksforgeeks.org/merge-sort/
# Python program for implementation of MergeSort 
def Merge_Sort(arr): 
    if len(arr) >1: #Checks for positive integers in the array
        mid = len(arr)//2 #Divides the array in two
        L = arr[:mid] # assigns L as left hand side sub array
        R = arr[mid:] # assigns R as right hand side sub array
  
        Merge_Sort(L) # Sorts the Left hand side
        Merge_Sort(R) # Sorts the right hand side
  
        i = j = k = 0 #sets all indices to 0
          
        # Copy data to temp arrays L[] and R[] 
        while i < len(L) and j < len(R): #check each item in both subarrays
            if L[i] < R[j]: 
                arr[k] = L[i] 
                i+=1
            else: 
                arr[k] = R[j] 
                j+=1
            k+=1
          
        # Checking all elements in Left sub array
        while i < len(L): #While loop to check each item in array
            arr[k] = L[i] 
            i+=1
            k+=1
         
        # Checking all elements in Right sub array  
        while j < len(R): #While loop to check each item in array
            arr[k] = R[j] 
            j+=1 
            k+=1
  
# Code to print the list 
def printList(arr): 
    for i in range(len(arr)):         
        print(arr[i],end=" ") 
    print() 
  
# driver code to test the above code 
if __name__ == '__main__': 
    arr = [12, 11, 13, 5, 6, 7]  
    print ("Given array is", end="\n")  
    printList(arr) 
    Merge_Sort(arr) 
    print("Sorted array is: ", end="\n") 
    printList(arr)<jupyter_output>Given array is
12 11 13 5 6 7 
Sorted array is: 
5 6 7 11 12 13<jupyter_text>INSERTION SORT<jupyter_code>import time #import time function 
start = time.time() #start time
#credit https://www.pythoncentral.io/insertion-sort-implementation-guide/
def insertion_Sort(alist):
    for i in range(1,len(alist)): #for each element in thr list to be sorted
        #element to be compared
        current = alist[i] 
        #comparing the current element with the sorted portion and swapping
        while i>0 and alist[i-1]>current: #compare each element with the previous one
            alist[i] = alist[i-1]
            i = i-1
            alist[i] = current #swap replaced element with current one
    return alist
print(insertion_Sort([7,1,3,5,9,2,3]))
end = time.time() #end time
print(end - start) #outputs time to execute method
num_runs = 10 # number of times to run the function
results = [] #array to store results for each test

#benchmark the function
import time
for r in range(num_runs):
    #log the start time in secs
    start_time = time.time()

    #call the function that you want to benchmark
    mergeSort(arr)
    #log the end time in secs
    end_time = time.time()
    # calculate the time elapsed
    time_elapsed = end_time - start_time

    results.append(time_elapsed)
print (mergeSort(random_array(10)))
print(time_elapsed*1000)<jupyter_output><empty_output><jupyter_text>Group the functions<jupyter_code>Functions = (Bubble_Sort, Bucket_Sort, Counting_Sort, Merge_Sort, Insertion_Sort)<jupyter_output><empty_output><jupyter_text>Write a Main Method<jupyter_code>#write main function to call all sorts
def(main):
    for r in len(range(n))
        for s in range (Functions)
print()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup