Uploaded by Fatih Kuru

Pseudocode

advertisement
Pseudocode
n = 1000
#declared n value
k=3
# Bigger than or equal to 2
sort11,sort21,sort31 = []
arr = np.random.randint(0,1000,(n))
np.split(arr,k)
#array has split into k arrays
def insertionSort()
#insertion sort algorithm
…
def mergeSort()
#merge sort algorithm
…
def merge()
…
for x in range (k)
#insertion sort implemented into subarrays of big array
insertionsort(split(x))
for I in range (len(split[0]))
sort11.append(split[0][i])
sort21.append(split[1][i])
sort31.append(split[2][i])
totalSort = sort11 + sort21 + sort31
#all arrays has been merged
mergeSort(totalSort,0,len(totalSort)-1)
#mergesort algorithm has been applied
print(totalSort)
Show that your algorithm is loop
invariant.
for x in range (k)
#insertion sort implemented into subarrays of big array
insertionsort(split(x))
for I in range (len(split[0]))
sort11.append(split[0][i])
sort21.append(split[1][i])
sort31.append(split[2][i])
As it can be seen from these lines, my algorithm is NOT loop invariant.
Runtimes
For Small dataset
For Medium Dataset
For Large Dataset
Download