Question: Given an array 5 8 , 5 3 , 4 6 , 9 8 , 1 7 , 2 5 , 7 9 , 3
Given an array and a gap value of :
What is the array after shell sort with a gap value of
comma between values
This is the algorithm it follows:
InsertionSortInterleavednumbers numbersSize, startIndex, gap
i
j
temp Temporary variable for swap
for i startIndex gap; i numbersSize; i i gap
j i
while j gap startIndex && numbersj numbersj gap
temp numbersj
numbersj numbersj gap
numbersj gap temp
j j gap
ShellSortnumbers numbersSize, gapValues
for each gapValue in gapValues
for i ; i gapValue; i
InsertionSortInterleavednumbers numbersSize, i gapValue
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
