A selection sort searches an array looking for the smallest


A selection sort searches an array looking for the smallest element int he array. When the smallest element is found, it is swapped with the first element of the array. The process is the repeated for the sub-array, beginning with the second element of the array. Each pass of the array results in one element being placed in its proper location. This sort requires processing capabilities similar to those of the bubble sort: for an array of n elements, n-1 passes must be made, and for each sub-array, n-1 comparisons must be made to find the smallest value. When the sub-array being processed contains one element, the array is sorted. Write a non-recursive (i.e., iterative) function selectionSort() to perform this algorithm. Use it in a program that reads from a file a sequence of integers (one per line in the file) from a file that is specified as a command- line argument to your program. Make no assumptions on the number of integers (lines in the file) that may be given to your program. Have your program print the sorted list, one number per line, with no non-number lines (i.e., no other messages or symbols, just the sorted list of numbers).

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: A selection sort searches an array looking for the smallest
Reference No:- TGS0145446

Expected delivery within 24 Hours