CS 2114 Chapter Notes - Chapter Sorting: Selection Sort, Pseudocode, The Algorithm

103 views4 pages

Document Summary

Sorting arranges things into either ascending or descending order. Using the method compareto is very helpful (implement the interface. Sorting an array is typically easier than sorting a chain of linked nodes. Can organize methods that sort an array by creating a class of static methods that perform the various sorts. The methods define a generic type t for the objects in the array: example: for an array to be sortable, the objects in the array much be. Comparable, so that interface but me implemented. public static > void sort(t[] a, int n) For example, suppose one wanted to sort books on a bookshelf by: example: a class for sorting an array using selection sort. height. One would fine the shortest book and move it to the far end. The original far end is swapped with the other entry.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents