• Home
  • University of the People
  • Data Structures (proctored course) CS 3303
  • Sorting Algorithms in Data Structures

Sorting Algorithms in Data Structures

CS 3303 discussion unit 6 Sorting Algorithm Assignment My description and asymptotic analysis: My algorithm implements a quicksort because this method constantly provides the best case scenario whenever the array is not sorted and in this situation the array isn't sorted. Insertsort provides the best case scenario whenever the array is already sorted and this method is favored for small arrays. All functions run in O(1) or O(n) aside from sorting so the main function runs at the same moment as the optimized quicksort. Quicksort utilizes recursive partitioning in order to organize an array of numbers into a generally sorted order until optimalPartitionSize is accomplished within every sub partition. The array which has been sorted the most is then completely sorted utilizing insertionsort to maintain the exchange of elements down to a minimum. The absolute number of exchanges is conveyed to the console before this method returns. If the optimalPartitionSize is equal to 1 the quicksort will then provide us with the worst case runtime of O(n^2) and the best case runtime of O(nlog(n)). If the optimalPartitionSize is greater than 1 then we would probably run insertionsort on the entire array which will cause this quicksorts runtime to become contaminated. Insertionsort possesses a runtime of O(n^2) in the worst case and O(n) in the best case FindPivot is enhanced for random lists of data. Asymptotic analysis is O(1) in this scenario because there are no loops located within this function. The necessary amount of exchanges in my output was 32 while the insertion sort example which was provided within the assignment possessed 114 exchanges.