fendyli433 fendyli433
  • 28-06-2019
  • Computers and Technology
contestada

Sort the array A = [ 3, 1, 4, 1, 5, 9, 2, 6, 5] using insertion sort and illustrate your solution?

Respuesta :

SerenaBochenek SerenaBochenek
  • 12-07-2019

Answer:

Sorted list : [1, 1, 2, 3, 4, 5, 5, 6, 9]

Explanation:

For j= 2 to length of A

we find the place for A[j] in the sub-array A[1,..., j]

Taking i from j-1 to 1, if A[i] is greater than A[j] we shift it to right.

Ver imagen SerenaBochenek
Answer Link

Otras preguntas

Add: 2 gal 3 qt 1 pt + 4 gal 1 qt
Which of the following statements is true?A. The matter in an ecosystem must be continuously replenished.B. The total amount of energy in an ecosystem remains t
What happens during the cytokinesis phase of meiosis? a. homologous chromosomes pair and form synapses c. chiasmata separate b. bivalents align at the metaphase
Why did Roosevelt set aside millions of acres for national parks and wildlife?
How does sound travel and where does it travel better? please help!
Graph the exponential function. Y=5(2)^x
Fifteen grams of a liquid plastic are frozen in a physical change that increases the volume. What can be known about the plastic after the change? It will weigh
A ball is dropped from a height of 6 feet and begins bouncing. The height of each bounce is three-fourths the height of the previous bounce. Find the total vert
The climax of the story “Seventh Grade”
The rockpile is part of the storys settings what happened there ? A-the neighborhood boys played and fought on it B-a boy from the neighborhood drowned C-joh