Question: Given an array 5 8 , 5 3 , 4 6 , 9 8 , 1 7 , 2 5 , 7 9 , 3

Given an array 58,53,46,98,17,25,79,37,30,22 and a gap value of 4 :
What is the array after shell sort with a gap value of 4?
(comma between values)
This is the algorithm it follows:
InsertionSortInterleaved(numbers, numbersSize, startIndex, gap){
i =0
j =0
temp =0// Temporary variable for swap
for (i = startIndex + gap; i numbersSize; i = i + gap){
j = i
while (j - gap >= startIndex && numbers[j] numbers[j - gap]){
temp = numbers[j]
numbers[j]= numbers[j - gap]
numbers[j - gap]= temp
j = j - gap
}
}
}
ShellSort(numbers, numbersSize, gapValues){
for each (gapValue in gapValues){
for (i =0; i gapValue; i++){
InsertionSortInterleaved(numbers, numbersSize, i, gapValue)
}
}
}
 Given an array 58,53,46,98,17,25,79,37,30,22 and a gap value of 4 :

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!