Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7.6.9 I'm not sure how to start. Please answer all parts using the given format. Thank you! RUN CODE TEST CASES ASSIGNMENT DOCS GRADE MORE

7.6.9 I'm not sure how to start. Please answer all parts using the given format. Thank you! image text in transcribed
image text in transcribed
image text in transcribed
RUN CODE TEST CASES ASSIGNMENT DOCS GRADE MORE 7 points Status: Not Submitted Instead of ordering Insertion Sort in ascending order, change the code to sort in descending order. Hint: Where are items compared? Try writing out the steps in the algorithm on paper to help. 7 ca codes.com/student/2087860/section/148661/assignment/5896269/ Sandbox My Section Practice Status: Not Submitted M 0 !!! FILES InsertionSortava 7.6.9: Explore Insertion Sort Sumit. Continue 1 import java.util.Arrays: 2 3 public class Insertion Sort 4-1 5 public static void main(String[] args) 6- { 7 int[] arrayi - 19, 8, 7, 6, 5, 4, 3, 2, 1); 8 int array2 - 5, 6, 4, 8, 9, 7, 3, 1, 2): 9 10 System.out.print("First array: "); 11 Systen, out.println(Arrays.toString(array)); 12 System.out.print("Second array: "); 13 System.out.println(Arrays.toString(array2)); 14 System.out.printlno: 15 16 // sort first arpay 17 insertionSortCartay1); 18 // sort second arrdy 19 insertionSort(array2); 20 21 System.out.print("First array sorted: "); 22 System.out.println(Arrays.toStringCarray1)); 23 System.out.print("Second array sorted: "); System.out.println(Arrays.toString(array2)): 25 } 26 ord 29 38 31 Insertion sort takes in an array of integers and * returns o sorted array of the some integers. public static void insertionSort(intorr) 131 Oy MacBook Pro 20 ET ra og S % 2 3 4 5 6 7 8 codehs.com/student/2087850/section/148661/assignment/5896269/ Sandbox My Section Practice Status: Not Submitted 7.6.9: Explore Insertion Sort Submit. Continue M 6- 7 8 9 int array1 - {9, 8, 7, 6, 5, 4, 3, 2, 1); int[] array2 - {5, 6, 4, 8, 9, 7, 3, 1, 2): FILES Insertion Sort java 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 System.out.print("First array: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array: "); System.out.println(Arrays.toString(array2)); System.out.printlno: // sort first array insertionSortCarray1); W sort second array insertionSort(array23 System.out.print("First array sorted: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array sorted: "); System.out.println(Arrays.toString(array2)); } Insertion sort takes in an array of integers and returns a sorted array of the same integers. public static void insertionSort(int arr) { 31 32 33 34 35 36) } 0- 31 100 OLE MacBook Pro ODD de 2 3 4 5 6 7 8 RUN CODE TEST CASES ASSIGNMENT DOCS GRADE MORE 7 points Status: Not Submitted Instead of ordering Insertion Sort in ascending order, change the code to sort in descending order. Hint: Where are items compared? Try writing out the steps in the algorithm on paper to help. 7 ca codes.com/student/2087860/section/148661/assignment/5896269/ Sandbox My Section Practice Status: Not Submitted M 0 !!! FILES InsertionSortava 7.6.9: Explore Insertion Sort Sumit. Continue 1 import java.util.Arrays: 2 3 public class Insertion Sort 4-1 5 public static void main(String[] args) 6- { 7 int[] arrayi - 19, 8, 7, 6, 5, 4, 3, 2, 1); 8 int array2 - 5, 6, 4, 8, 9, 7, 3, 1, 2): 9 10 System.out.print("First array: "); 11 Systen, out.println(Arrays.toString(array)); 12 System.out.print("Second array: "); 13 System.out.println(Arrays.toString(array2)); 14 System.out.printlno: 15 16 // sort first arpay 17 insertionSortCartay1); 18 // sort second arrdy 19 insertionSort(array2); 20 21 System.out.print("First array sorted: "); 22 System.out.println(Arrays.toStringCarray1)); 23 System.out.print("Second array sorted: "); System.out.println(Arrays.toString(array2)): 25 } 26 ord 29 38 31 Insertion sort takes in an array of integers and * returns o sorted array of the some integers. public static void insertionSort(intorr) 131 Oy MacBook Pro 20 ET ra og S % 2 3 4 5 6 7 8 codehs.com/student/2087850/section/148661/assignment/5896269/ Sandbox My Section Practice Status: Not Submitted 7.6.9: Explore Insertion Sort Submit. Continue M 6- 7 8 9 int array1 - {9, 8, 7, 6, 5, 4, 3, 2, 1); int[] array2 - {5, 6, 4, 8, 9, 7, 3, 1, 2): FILES Insertion Sort java 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 System.out.print("First array: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array: "); System.out.println(Arrays.toString(array2)); System.out.printlno: // sort first array insertionSortCarray1); W sort second array insertionSort(array23 System.out.print("First array sorted: "); System.out.println(Arrays.toString(array1)); System.out.print("Second array sorted: "); System.out.println(Arrays.toString(array2)); } Insertion sort takes in an array of integers and returns a sorted array of the same integers. public static void insertionSort(int arr) { 31 32 33 34 35 36) } 0- 31 100 OLE MacBook Pro ODD de 2 3 4 5 6 7 8

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions