Question: Write a Java function to sort an unordered singly linked list of ints using the selection sort algorithm: create an empty list named sorted. while
Write a Java function to sort an unordered singly linked list of ints using the selection sort algorithm: create an empty list named sorted. while (unsorted is not empty) { scan unsorted to find the max element remove max element from unsorted and insert to head in sorted } To demonstrate your program workes, do the following: create unsorted with elements {5, 3, 1, 2, 7} output unsorted sort unsorted data into sorted output sorted Constraints: (1) One one file for all code. (2) Hardcode the data. (3) You must create and use the class that describes objects (nodes) in the lists unsorted and sorted. (4) unsorted and sorted use the same Node class. (5) The Node class data fields are *only* an int and a reference to Node (6) You must write the sort code (not use publicly available code) (7) Your sort must work on singly linked list.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
