Question: An insertion sort sorts an array by successively inserting the elements of the array into the sorted portion. The pseudocode describes the algorithm. Note that
An insertion sort sorts an array by successively inserting the elements of the array into the sorted portion. The pseudocode describes the algorithm. Note that arrays start from so the first element of an N element array is A and the last element is AN
Given: An array A of size N to be sorted
Function InsertionSortA N
Let j
While j N
Let i j
While i & Ai Ai
Swap Ai and Ai
Decrement i
Increment j
Which line above shows that the sorted segment is being scanned from right to left?
Line
Line
Line
Line
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
