MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
In doing shell sort algorithm, what will you do after you swapped the values using the Knuth’s formula and the interval of 1?
A
Sort the remaining sub list using bubble sort
B
Identify the pivot value then implement merge sort
C
Use insertion sort
D
all of the above
Explanation: 

Detailed explanation-1: -Step 1: Set the value of i. Step 2: Separate the list into sub-lists with the same i interval. Step 3: Using insertion sort, sort these sub-lists. Step 4: Continue until the entire list has been sorted.

Detailed explanation-2: -However the Knuth sequence is (k * 3-1)/2 and a list of the first few gaps is usually represented as [1, 4, 13, 40, 121.. and so on].

Detailed explanation-3: -Shell sort is mainly a variation of Insertion Sort. In insertion sort, we move elements only one position ahead. When an element has to be moved far ahead, many movements are involved. The idea of ShellSort is to allow the exchange of far items.

Detailed explanation-4: -Conclusion. Shell sort is one the most efficient sorting algorithm for large datasets. This technique is based on insertion sort but it reduces the no. of swaps considerably.

There is 1 question to complete.