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

Solve each equation by factoring. 12-27n^2=0
All of the following could be considered evidences of evolution EXCEPT (A) the structural homology between the forearms of bats and humans. (B) the DNA sequence
Solve each equation by factoring. 12-27n^2=0
explain the impact of andrew Jackson's election on the spoil system?
Solve each equation by factoring. 12-27n^2=0
what occurs during the perception process?
omnivores and carnivores of boreal forest
explain the impact of andrew Jackson's election on the spoil system?
Is radioactivity on the Earth something relatively new?
Which instrument is used to measure the gain or loss of heat? (A)manometer (B)hydrometer (C)calorimeter (D)barometer (E)voltmeter