Purpose: Use arrays, dynamic memory allocation, and XXXXXXXXXXsorting algorithms. Description: Write four array processing functions: - a function to load an integer array with a random set of...

Purpose: Use arrays, dynamic memory allocation, and XXXXXXXXXXsorting algorithms.   Description:    Write four array processing functions:   - a function to load an integer array with a random     set of integers   - a function to sort an integer array using bubble     sort   - a function to sort an integer array using selection     sort   - a function to sort an integer array using insertion     sort    Write a test program that reads in one command-line    argument that is the size of an array to create using   dynamic memory allocation. Have the program create    the array, and then load the array with random values,    and then call each of of the sort functions. Repeat    the loading of random values and calling of the sort    functions to show that all three of the sorts actually   work XXXXXXXXXXNotes: XXXXXXXXXXWrite a main( ) to exercise your functions and to    illustrate that the functions are working properly XXXXXXXXXXThis is known as a driver program. It "drives/tests" some     other function/code XXXXXXXXXXSee Prata, bottom of pg XXXXXXXXXXPrint the values in the array, before and after     each sort, to show that the sorting actually works XXXXXXXXXXNicely format and label your output  E-mail your source code to Otto.  Pseudocode for sorts: ====================  Bubble sort: =========== pass = 0 while pass < SIZE - 1 do:      item = SIZE XXXXXXXXXXwhile item > pass do: XXXXXXXXXXif ar[item] > ar[item - 1] XXXXXXXXXXthen XXXXXXXXXXtemp = ar[item] XXXXXXXXXXar[item] = ar[item - 1] XXXXXXXXXXar[item - 1] = temp XXXXXXXXXXend if XXXXXXXXXXend while XXXXXXXXXXpass = pass XXXXXXXXXXend while ------- XXXXXXXXXXXXXXXXXXXXSelection sort: ============== pass = 0 while pass < SIZE - 1 do:      position = pass XXXXXXXXXXitem = pass XXXXXXXXXXwhile item < SIZE do: XXXXXXXXXXif ar[position] < ar[item] XXXXXXXXXXthen XXXXXXXXXXposition = item XXXXXXXXXXend if XXXXXXXXXXif pass != position XXXXXXXXXXtemp = ar[pass] XXXXXXXXXXar[pass] = ar[position] XXXXXXXXXXar[position] = temp XXXXXXXXXXend if XXXXXXXXXXitem = item XXXXXXXXXXend while XXXXXXXXXXpass = pass XXXXXXXXXXend while ------- XXXXXXXXXXXXXXXXXXXXInsertion sort: ============== ordered = 0  pass = ordered while pass < SIZE - 1 do:      item = pass XXXXXXXXXXwhile (item > 0) AND (ar[item] > ar[item - 1]) do: XXXXXXXXXXtemp = ar[item - 1] XXXXXXXXXXar[item - 1] = ar[item] XXXXXXXXXXar[item] = temp XXXXXXXXXXitem = item XXXXXXXXXXend while XXXXXXXXXXpass = pass XXXXXXXXXXend while
May 01, 2021

Submit New Assignment

Copy and Paste Your Assignment Here