NEW
Font size
WorksheetsQuiz No. 3 (Finals)
Total questions: 20
Worksheet time: 11mins
is an algorithm that first sorts the elements far apart from each other and successively reduces the interval between the elements to be sorted. It is a generalized version of insertion sort
Shell Sort
Merge Sort
Quick Sort
In shell sort, elements at a specific interval are sorted. The interval between the elements is gradually decreased based on the sequence used.
True
False
What is shell's original sequence?
1, 4, 13, …, (3k – 1) / 2
N/2 , N/4 , …, 1
1, 8, 23, 77, 281, 1073, 4193, 16577...4j+1+ 3·2j+ 1
1, 3, 5, 9, 17, 33, 65,...
In shell sort, we compare elements that are distant apart and rather than adjacent.
True
False
What is the best case complexity of shell sort?
O(n*log n)
O(n2)
O(xn*log n2)
O(2*log n)
is a recursive algorithm that continually splits a list in half. If the list is empty or has one item, it is sorted by definition (the base case).
Shell Sort
Merge Sort
Quick Sort
is the process of taking two smaller sorted lists and combining them together into a single, sorted, new list.
Sorting
Merging
Separating
When using this technique, we divide a problem into subproblems. When the solution to each subproblem is ready, we 'combine' the results from the subproblems to solve the main problem.
Divide Technique
Divide and Conquer Technique
Split and Combine Technique
Combine Technique
In merge sort, The algorithm maintains two pointers, one for each of the two arrays and one for maintaining the current index of final sorted array.
True
False
uses divide and conquer to gain the same advantages as the merge sort, while not using additional storage. As a trade-off, however, it is possible that the list may not be divided in half.
Shell Sort
Merge Sort
Quick Sort
A quick sort first selects a value, which is called the
variable x
x value
pivot value
variable of pivot
The actual position where the pivot value belongs in the final sorted list, commonly called the combine point, will be used to divide the list for subsequent calls to the quick sort.
True
False
A pivot element is chosen from the array. You can choose any element from the array as the pivot element.
True
False
The array is divided into subparts taking pivot as the partitioning point. The elements smaller than the pivot are placed to the left of the pivot and the elements greater than the pivot are placed to the right.
Divide
Conquer
Combine
The left and the right subparts are again partitioned using the by selecting pivot elements for them. This can be achieved by recursively passing the subparts into the algorithm
Divide
Conquer
Combine
This step does not play a significant role in quicksort. The array is already sorted at the end of the conquer step.
Divide
Conquer
Combine
What is the worst-case complexity of Quick Sort?
O(n2)
O(n*log n)
O(2*log n)
O(n2)^2
