2.15 LAB: Descending selection sort with output during execution Write a program that takes an integer list as input and sorts the list into descending order using selection sort. The program should use nested loops and output the list after each iteration of the outer loop, thus outputting the list N-1 times (where N is the size of the list). Important Coding Guidelines: • Use comments, and whitespaces around operators and assignments. • Use line breaks and indent your code. • Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code. • Write simple code and do not over complicate the logic. Code exhibits simplicity when it's well organized, logically minimal, and easily readable. Ex: If the input is: 20 10 30 40 the output is: [40, 10, 30, 20] [40, 30, 10, 20] [40, 30, 20, 10] Ex: If the input is: 7 8 3 the output is: [8, 7, 3] [8, 7, 3]
Added by Tom-S C.
Close
Step 1
After each iteration of the outer loop, the current state of the list should be printed. This means you will see the list becoming more sorted with each step. Step 2: Plan the Solution To solve this problem, you will need to: - Take an input list of integers. - Show more…
Show all steps
Your feedback will help us improve your experience
Aarya B and 78 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a program that gets a list of integers from input and outputs non-negative integers in ascending order (lowest to highest). For example, if the input is: 10 -7 4 39 -6 12 2, the output should be: 2 4 10 12 39. For coding simplicity, follow every output value by a space. Do not end with a newline. This program is written in the Python language.
Shelayah R.
(Sort three integers) Write a program that prompts the user to enter three integers and displays them in increasing order.
Write a program that asks the user for three numbers and prints the numbers in either ascending or descending order according to the user's choice. For example, Enter number a: 3 Enter number b: 1 Enter number c: 6 Ascending order (Y or N): y In ascending order: 1.00, 3.00, 6.00 or Enter number a: 4 Enter number b: 5 Enter number c: 9 Ascending order (Y or N): N In descending order: 9.00, 5.00, 4.00 Requirement: This program should contain only one print() statement. You should build the output using string concatenation.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD