CPS 109 Study Guide - Quiz Guide: Dynamic Array, Selection Sort

168 views11 pages

Document Summary

In each of the following program files, the part that you had to write is between the and comments. Tests the selectionsorter class import java. util. public class selectionsortertester public static void main(string[] args) int[]a = new int[]{14, 2, 19, 3, 15, 22, 18, 7} ; System. out. println(--------------------------------) ; a = randomintarray(40, 100) ; sorter = new selectionsorter(a) ; @return a string like [a1, a2, , a_n] public static string tostring(int[] array) @return an array filled with length random numbers between 0 and n - 1 public static int[] randomintarray(int length, int n) int[] a = new int[length] ; Sorts an array of integers using the selection sort algorithm. Note: if two elements are equal in terms of sorting, do not change their order (don"t swap their positions). public class selectionsorter private int[] a ; @param anarray the array to sort public selectionsorter(int[] anarray) a = anarray ;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents