Consider the following Insertion Sort algorithm and the array of integers provided - then answer the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following Insertion Sort algorithm and the array of integers provided - then answer the questions below: private static void InsertionSort (int[] List, int NrEl) { 0 1 } for (int i = 0; i < NrEl 1; i++) { } 2 for (int j = i + 1; j > 0; j--) { } 3 if (List[j-1] > List[j]) { } 4 int temp List[j-1]; List[j- 1] = List[j]; List[j] = temp; 5 6 80 60 11 31 17 9 6 a. Will the Sort above sort the list in ascending or descending order? b. Give the contents of the array after pass (each iteration of the outer for loop) Consider the following Insertion Sort algorithm and the array of integers provided - then answer the questions below: private static void InsertionSort (int[] List, int NrEl) { 0 1 } for (int i = 0; i < NrEl 1; i++) { } 2 for (int j = i + 1; j > 0; j--) { } 3 if (List[j-1] > List[j]) { } 4 int temp List[j-1]; List[j- 1] = List[j]; List[j] = temp; 5 6 80 60 11 31 17 9 6 a. Will the Sort above sort the list in ascending or descending order? b. Give the contents of the array after pass (each iteration of the outer for loop)
Expert Answer:
Answer rating: 100% (QA)
Lets go step by step and answer both of the questions presented a Will the Sort above sort the list ... View the full answer
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
A compare-exchange operation on two array elements A[i] and A[j], where i < j, has the form COMPARE-EXCHANGE (A, i, j) 1 If A[i] > A[j] 2 exchange A[i] with A[j] After the compare-exchange operation,...
-
Cungs Dress Delivery operates a mail-order business that sells clothes designed for frequent travelers. It had sales of $610,000 in December. Because Cungs Dress Delivery is in the mail order...
-
Safe Travel produces car seats for children from newborn to 2 years old. Safe Travel's only problem with its car seats was stitching in the straps. The problem can usually be detected and repaired...
-
In 1991, chemists at the University of Iowa were able to prepare trifluoromethylcopper(I), F 3 CCu. This compound could be used to prepare trifluoromethyl-substituted aromatic compounds by reactions...
-
Twenty motors are put on an accelerated life test without replacement and the test is truncated after 5 failures. If the first 5 failures occurred at 12.5, 16.8, 24.3, 27.6 and 32.1 hours, assuming...
-
Provide an example of an organism within each of the four main nutritional categories of microbes and describe how each obtains its essential nutrients.
-
Two individuals, Catherine and Annabelle, wish to make exchanges. Catherine has three pencils and Annabelle also has three. Catherine values successive units of pencil as follows: $6, $5, $4, $3, $2,...
-
On January 1, 2024, Marigold Company purchased 8,568 shares of Swifty Company's common stock for $123,000. Immediately after the stock acquisition, the statements of financial position of Marigold...
-
Martin Stanaway is the partner in charge of the audit for a new client, Western Wonderland (WW). The client engaged Martin's audit firm in November 2017, in preparation for the 2018 audit. From 30...
-
Written Assignment: Answer each below using correct grammar, punctuation and complete sentences. 1. Identify and discuss four basic steps in a risk management program. 2. Define concepts of...
-
A 1500 kg car goes from 20.0 m/s to 8.33 m/s in 5.0 s. Calculate the acceleration and the force on the car? (i). (ii). How long does it take for the car to come to a complete stop
-
Charlotte Webb is visiting her sister Paula at her home in San Francisco, California. Because of the pandemic, Charlotte and Paula have not seen each other in over two years and the two make plans...
-
when Judy adds 1 . 0 kg of unknown liquid at a temperature of 2 5 \ deg c to 2 . 0 kg of water at a temperature of 4 5 \ deg c , the final temperature of the mixture is 4 0 \ deg c , assuming no loss...
-
What are the three component systems of the movie industry? Explain in details.
-
According to your textbook, in an uncertain environment, managers want to develop _________ plans. a. general and flexible b. specific but flexible c. formal d. contingency
-
Pearl Medavoy will invest $10,240 a year for 20 years in a fund that will earn 10% annual interest. . If the first payment into the fund occurs today, what amount will be in the fund in 20 years? If...
-
What are the two kinds of static members?
-
Whats wrong with this statement? string programming Pioneer = "Admiral Grace Hopper";
-
Write the header for a catch block that catches either an InvalidPathException or a NoSuchFileException.
-
What are the pros and cons of basing a custody decision on the stated preference of a child?
-
What impact does witnessing spousal abuse have on children? For what other reasons do courts take intra-spousal violence into account when deciding custody?
-
Post-Palmore, can race and culture ever be taken into account when deciding custody? Explain.
Study smarter with the SolutionInn App