Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You'll be given a list of students, and you'll need to sort it using selection sort. We want to sort the students according to graduation

You'll be given a list of students, and you'll need to sort it using selection sort. We want to sort the students according to graduation year (soonest first), and for students with the same graduation year, alphabetically by first name (and if there are any students with the same first name and graduation year, ties should be broken by last name). However, rather than just printing the final sorted list, you'll print the partially sorted list after each pass (equivalently, after each selection of the smallest element).

Input Format

The first line of the input consists of an integer, n, indicating the number of words you'll need to sort. The next n lines will each consist of student data wtih space-separated first name, last name, and graduation year, in that order. The input will terminate with a blank line. For example:

6 priya murali 2018 stephanie rothermel 2018 lilly wang 2016 stephanie liu 2018 annika fusco 2016 diane wang 2014 

Constraints

You can assume n is a non-negative integer. You can further assume the list contains no students with the same first name, last name, and graduation year.

Output Format

You will be printing the partially sorted list n - 1 times (the last time will be entirely sorted). Each student should appear on a new line without terminating whitespace, space separated in the same format it was provided in the input, and each partially sorted list should be followed by a blank line to indicate where it ends and the next one begins. For example:

diane wang 2014 stephanie rothermel 2018 lilly wang 2016 stephanie liu 2018 annika fusco 2016 priya murali 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 stephanie liu 2018 stephanie rothermel 2018 priya murali 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 stephanie liu 2018 stephanie rothermel 2018 priya murali 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 priya murali 2018 stephanie rothermel 2018 stephanie liu 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 priya murali 2018 stephanie liu 2018 stephanie rothermel 2018 

Sample Input 0

6 priya murali 2018 stephanie rothermel 2018 lilly wang 2016 stephanie liu 2018 annika fusco 2016 diane wang 2014 

Sample Output 0

diane wang 2014 stephanie rothermel 2018 lilly wang 2016 stephanie liu 2018 annika fusco 2016 priya murali 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 stephanie liu 2018 stephanie rothermel 2018 priya murali 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 stephanie liu 2018 stephanie rothermel 2018 priya murali 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 priya murali 2018 stephanie rothermel 2018 stephanie liu 2018 diane wang 2014 annika fusco 2016 lilly wang 2016 priya murali 2018 stephanie liu 2018 stephanie rothermel 2018

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago