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          sorting 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.             Notes: ----- - Write a main( ) to exercise your functions and to    illustrate that the functions are working properly.       (This is known as a driver program. It "drives/tests" some     other function/code.        - See Prata, bottom of pg. 232)    - Print the values in the array, before and after     each sort, to show that the sorting actually works.     - Nicely 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" -="" 1="" while="" item=""> pass do:         if ar[item] > ar[item - 1]             then                  temp = ar[item]                 ar[item] = ar[item - 1]                 ar[item - 1] = temp          end if              end while        pass = pass + 1      end while -------------------------------------------   Selection sort: ============== pass = 0 while pass < size="" -="" 1="" do:="" position="pass" item="pass" +="" 1="" while="" item="">< size="" do:="" if="" ar[position]="">< ar[item]="" then="" position="item" end="" if="" if="" pass="" !="position" temp="ar[pass]" ar[pass]="ar[position]" ar[position]="temp" end="" if="" item="item" +="" 1="" end="" while="" pass="pass" +="" 1="" end="" while="" -------------------------------------------="" insertion="" sort:="=============" ordered="0" pass="ordered" while="" pass="">< size="" -="" 1="" do:="" item="pass" +="" 1="" while="" (item=""> 0) AND (ar[item] > ar[item - 1]) do:         temp = ar[item - 1]         ar[item - 1] = ar[item]         ar[item] = temp          item = item - 1              end while        pass = pass + 1      end while
May 01, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here