Sorting Algorithms

Name: _____________________

Date: _____________________

Instructions: Answer all questions. Write your answers clearly in the space provided.

Question 1:

What is the key idea behind the Bucket Sort algorithm?

A. Sorting elements based on their frequency.
B. Sorting elements by swapping.
C. Distributing elements into buckets and sorting each bucket individually.
D. Sorting elements by comparing them.
Answer: _________
Question 2:

Which sorting algorithm is the best choice for sorting a small number of elements with a known range?

A. Merge Sort
B. Quick Sort
C. Heap Sort
D. Counting Sort
Answer: _________
Question 3:

What is the average-case time complexity of Merge Sort?

A. O(n log n)
B. O(n 2 )
C. O(n)
D. O(log n)
Answer: _________
Question 4:

Which sorting algorithm is described as an in-place algorithm but not stable?

A. Radix Sort
B. Counting Sort
C. Merge Sort
D. Quick Sort
Answer: _________
Question 5:

Which sorting algorithm requires a specific implementation for handling large integer values?

A. Bubble Sort
B. Selection Sort
C. Radix Sort
D. Insertion Sort
Answer: _________
Question 6:

What is the advantage of using TimSort over other sorting algorithms?

A. It does not require extra space.
B. It combines the best aspects of Merge Sort and Insertion Sort.
C. It is easier to implement.
D. It does not require extra space.
Answer: _________
Question 7:

In which scenario would you prefer to use Shell Sort?

A. When you need a stable sort.
B. When the array is very small.
C. When the array is large and unsorted.
D. When the array is nearly sorted.
Answer: _________
Question 8:

What is the time complexity of Heap Sort in the best case scenario?

A. O(n)
B. O(n 2 )
C. O(log n)
D. O(n log n)
Answer: _________
Question 9:

Which sorting algorithm uses a divide-and-conquer approach but is not comparison-based?

A. Heap Sort
B. Merge Sort
C. Radix Sort
D. Quick Sort
Answer: _________
Question 10:

What is the primary disadvantage of using Quick Sort?

A. It requires additional space.
B. It is not efficient for small arrays.
C. It is not stable.
D. It has a worst-case time complexity of O(n 2 ).
Answer: _________
Question 11:

Which of the following sorting algorithms has a worst-case time complexity of O(n log n) and is also stable?

A. Merge Sort
B. Quick Sort
C. Heap Sort
D. Selection Sort
Answer: _________
Question 12:

How does Radix Sort handle sorting of large numbers efficiently?

A. By directly sorting large numbers.
B. By using a comparison-based approach.
C. By dividing numbers into smaller groups.
D. By sorting numbers digit by digit using a stable sort algorithm.
Answer: _________
Question 13:

What is the time complexity of Selection Sort in the average case?

A. O(n log n)
B. O(n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 14:

Which sorting algorithm is best suited for sorting linked lists?

A. Heap Sort
B. Merge Sort
C. Insertion Sort
D. Heap Sort
Answer: _________
Question 15:

What is the key difference between Merge Sort and Quick Sort?

A. Merge Sort uses less space than Quick Sort.
B. Quick Sort is stable, while Merge Sort is not.
C. Merge Sort is stable and uses additional space, while Quick Sort is not stable and uses in-place sorting.
D. Merge Sort is faster than Quick Sort.
Answer: _________
Question 16:

Which sorting algorithm is known for its worst-case time complexity being better than O(n 2 )?

A. Bubble Sort
B. Quick Sort
C. Selection Sort
D. Merge Sort
Answer: _________
Question 17:

What is the time complexity of Counting Sort when the range of input values is very large?

A. O(n + k)
B. O(n log n)
C. O(k)
D. O(n 2 )
Answer: _________
Question 18:

Which sorting algorithm works by dividing the array into smaller parts and sorting those parts using recursion?

A. Counting Sort
B. Insertion Sort
C. Heap Sort
D. Merge Sort
Answer: _________
Question 19:

What type of data structure is used in the implementation of Heap Sort?

A. Binary Search Tree
B. AVL Tree
C. Binary Heap
D. Hash Table
Answer: _________
Question 20:

Which algorithm is typically used in applications where the input size is very large and a stable sort is required?

A. Heap Sort
B. Merge Sort
C. Radix Sort
D. Heap Sort
Answer: _________
Question 21:

Which of the following algorithm is implemented internally in java when we use function arrays.sort()?

A. intro sort
B. quick sort
C. tim sort
D. merge sort
Answer: _________
Question 22:

What is the worst case running time of shell sort using Hibbard's increments?

A. O(N)
B. O(N 2 )
C. O(N 1/2 )
D. O(N 3/2 )
Answer: _________
Question 23:

Find the pivot element from the given input using median-of-three partitioning method. 8, 1, 4, 9, 6, 3, 5, 2, 7, 0.

A. 8
B. 7
C. 9
D. 6
Answer: _________
Question 24:

Which of the following is an adaptive sorting algorithm?

A. binary insertion sort
B. merge sort
C. heap sort
D. selection sort
Answer: _________
Question 25:

Which of the following statement is true about comparison based sorting?

A. counting sort is a comparison based sort
B. any comparison based sorting can be made stable
C. bubble sort is not a comparison based sort
D. any comparison based sort requires at least O(n 2 ) time
Answer: _________
Question 26:

What is the worst case time complexity of recursive insertion sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 27:

What is the worst case time complexity of comb sort?

A. O(n 2 )
B. O(n log n)
C. O(n)
D. O(n 2 /2 a ) (a=number of increment)
Answer: _________
Question 28:

Any algorithm that sorts by exchanging adjacent elements require O(N 2 ) on average.

A. True
B. False
Answer: _________
Question 29:

Quick sort follows Divide-and-Conquer strategy.

A. True
B. False
Answer: _________
Question 30:

What is the worst case analysis of shell sort using Shell's increments?

A. O(N)
B. O(N 2 )
C. O(N 1/2 )
D. O(N 3/2 )
Answer: _________
Question 31:

What is the best case time complexity of binary insertion sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 32:

Which of the following is not true about tree sort?

A. it is not an in place sorting algorithm
B. its every implementation is adaptive
C. it requires in order traversal of BST for sorting input elements
D. it is a stable sort
Answer: _________
Question 33:

Sleep sort does not work for . . . . . . . .

A. negative numbers
B. large numbers
C. small numbers
D. positive numbers
Answer: _________
Question 34:

How many flips does the simplest of pancake sorting techniques require?

A. 3n-3 flips
B. 2n-4 flips
C. 2n-3 flips
D. 3n-2 flips
Answer: _________
Question 35:

Shell sort is applied on the elements 27 59 49 37 15 90 81 39 and the chosen decreasing sequence of increments is (5,3,1). The result after the first iteration will be

A. 27 59 49 37 15 90 81 39
B. 27 59 37 49 15 90 81 39
C. 27 59 39 37 15 90 81 49
D. 15 59 49 37 27 90 81 39
Answer: _________
Question 36:

Pancake Sorting appears in which of the following?

A. Frequency Scaling
B. Storage Virtualization
C. Parallel Processing
D. Neural Networking
Answer: _________
Question 37:

Which of the following is false?

A. Binary tree sort and quick sort have same running time
B. Binary tree sort used BST as work area
C. As the number of elements to sort gets larger, binary tree sort gets more and more efficient
D. Both quick sort and binary tree are in place sorting algorithms
E. LSD radix sort is an integer sorting algorithm
F. LSD radix sort is a comparison sorting algorithm
G. LSD radix sort is a distribution sort
H. LSD radix sort uses bucket sort
Answer: _________
Question 38:

What is the auxiliary space complexity of bottom up merge sort?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 39:

How many comparisons will be made to sort the array arr={1, 5, 3, 8, 2} using bucket sort?

A. 5
B. 7
C. 9
D. 0
Answer: _________
Question 40:

Which of the following algorithm is stable?

A. heap sort
B. cube sort
C. quick sort
D. bogosort
Answer: _________
Question 41:

What is the time taken to perform a delete min operation?

A. O(N)
B. O(N log N)
C. O(log N)
D. O(N 2 )
Answer: _________
Question 42:

Which of the following uses the largest amount of auxiliary space for sorting?

A. Bubble sort
B. Counting sort
C. Quick sort
D. Heap sort
Answer: _________
Question 43:

Which of the following is an in-place sorting algorithm?

A. Merge sort
B. Permutation sort
C. Radix sort
D. Counting sort
Answer: _________
Question 44:

What is the average case time complexity of standard merge sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 45:

What is the average case time complexity of binary insertion sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 46:

What is the best case time complexity of comb sort and bubble sort respectively?

A. O(n 2 ) and O(n log n)
B. O(n log n) and O(n)
C. O(n) and O(n 2 )
D. O(n 2 /2 a ) (a=number of increment) and O(n 2 )
Answer: _________
Question 47:

Merge sort uses which of the following method to implement sorting?

A. selection
B. exchanging
C. merging
D. partitioning
Answer: _________
Question 48:

The worst case time complexity of tree sort remains unaffected when implemented with an unbalanced tree or a balanced tree.

A. True
B. False
Answer: _________
Question 49:

Library sort is an online sorting algorithm.

A. true
B. false
Answer: _________
Question 50:

Sleep sort should be preferred over bogosort as it has better time complexity.

A. true
B. false
Answer: _________
Question 51:

What is an in-place sorting algorithm?

A. It needs O(1) or O(logn) memory to create auxiliary locations
B. The input is already sorted and in-place
C. It requires additional storage
D. It requires additional space
Answer: _________
Question 52:

Merge sort is preferred for arrays over linked lists.

A. true
B. false
Answer: _________
Question 53:

Shell sort uses a sequence called a incrementing sequence to sort the elements.

A. True
B. False
Answer: _________
Question 54:

Which of the following examples represent the worst case input for an insertion sort?

A. array in sorted order
B. array sorted in reverse order
C. normal unsorted array
D. large array
Answer: _________
Question 55:

Which of the following is not true about MSD radix sort?

A. its processing starts from the most significant digit
B. it is not a stable sort
C. it is an in place sorting algorithm
D. it is non comparison based sort
Answer: _________
Question 56:

How many iterations are required to sort the array arr={2, 3, 4, 5, 1} using bubble sort and cocktail sort respectively?

A. 4,2
B. 5,3
C. 5,2
D. 4,3
Answer: _________
Question 57:

Which of the following is a non-comparison sort?

A. heap sort
B. quick sort
C. merge sort
D. pigeonhole sort
Answer: _________
Question 58:

How many sub arrays does the quick sort algorithm divide the entire array into?

A. one
B. two
C. three
D. four
Answer: _________
Question 59:

What is the general form of Shell's increments?

A. 1,2,3,...,n
B. 1,3,7,....,2k-1
C. 1,3,5,7,....,k-1
D. 1,5,10,15,..., k-1
Answer: _________
Question 60:

What is the worst case time complexity of the Quick sort?

A. O(nlogn)
B. O(n)
C. O(n 3 )
D. O(n 2 )
Answer: _________
Question 61:

Which of the following is a comparison based sort?

A. tree sort
B. radix sort
C. counting sort
D. pigeonhole sort
Answer: _________
Question 62:

What is the worst case time complexity of library sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 63:

Choose the incorrect statement about merge sort from the following?

A. both standard merge sort and in-place merge sort are stable
B. standard merge sort has greater time complexity than in-place merge sort
C. standard merge sort has greater space complexity than in-place merge sort
D. in place merge sort has O(log n) space complexity
E. it is a comparison based sort
F. it is an adaptive algorithm
G. it is not an in place algorithm
H. it is stable algorithm
Answer: _________
Question 64:

What is the worst case time complexity of cycle sort?

A. O(n)
B. O(log n)
C. O(n log n)
D. O(n 2 )
Answer: _________
Question 65:

The gap value after 3 iterations in an array with 6 elements will be . . . . . . . .

A. 4
B. 3
C. 2
D. 1
Answer: _________
Question 66:

Which one of the following is a variation of Heap sort?

A. Comb sort
B. Smooth sort
C. Binary tree sort
D. Shell sort
Answer: _________
Question 67:

Heap sort is an implementation of . . . . . . . . using a descending priority queue.

A. insertion sort
B. selection sort
C. bubble sort
D. merge sort
Answer: _________
Question 68:

Shell sort algorithm is an example of?

A. Bottom-up sorting
B. In-place sorting
C. Internal sorting
D. External sorting
Answer: _________
Question 69:

Choose the correct statement about bottom up merge sort from the following?

A. bottom up merge sort has greater time complexity than standard merge sort
B. bottom up merge sort has lesser time complexity than standard merge sort
C. bottom up merge sort saves auxiliary space required on call stack
D. bottom up merge sort uses recursion.
Answer: _________
Question 70:

Which operation is most essential to the process of pancake sort?

A. Flip the given data
B. Find the largest of given data
C. Finding the least of given data
D. Inserting something into the given data
Answer: _________
Question 71:

Which among the following is the best cut-off range to perform insertion sort within a quick sort?

A. N=0-5
B. N=5-20
C. N=20-30
D. N>30
Answer: _________
Question 72:

Gnome sort is also called . . . . . . . .

A. Smart sort
B. Stupid sort
C. Bogo sort
D. Special sort
Answer: _________
Question 73:

Which is the worst method of choosing a pivot element?

A. first element as pivot
B. last element as pivot
C. median-of-three partitioning
D. random element as pivot
Answer: _________
Question 74:

Which of the following is not an advantage of optimised bubble sort over other sorting techniques in case of sorted elements?

A. It is faster
B. Consumes less memory
C. Detects whether the input is already sorted
D. Consumes less time
Answer: _________
Question 75:

Counting sort is often used as a sub routine for radix sort.

A. true
B. false
Answer: _________
Question 76:

Which of the following sorting algorithm was inspired by the natural phenomenon of falling objects?

A. bogo sort
B. heap sort
C. bead sort
D. strand sort
Answer: _________
Question 77:

Which of the following is a disadvantage of library sort when compared to insertion sort?

A. library sort has greater time complexity
B. library sort has greater space complexity
C. library sort makes more comparisons
D. it has no significant disadvantage
Answer: _________
Question 78:

Which is the safest method to choose a pivot element?

A. choosing a random element as pivot
B. choosing the first element as pivot
C. choosing the last element as pivot
D. median-of-three partitioning method
Answer: _________
Question 79:

What is the average time complexity of pigeonhole sort (k=range of input)?

A. O(n)
B. O(n+k)
C. O(n 2 )
D. O(n*k)
Answer: _________
Question 80:

Bogosort works by . . . . . . . .

A. generating random permutations of its input
B. partitioning the array
C. dividing the value of input elements
D. generating permutations according to the value of first element of array
Answer: _________
Question 81:

What is the average case time complexity of library sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 82:

What is the best case efficiency of bubble sort in the improvised version?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 83:

What is an internal sorting algorithm?

A. Algorithm that uses tape or disk during the sort
B. Algorithm that uses main memory during the sort
C. Algorithm that involves swapping
D. Algorithm that are considered 'in place'
Answer: _________
Question 84:

Consider the original array 17 8 12 4 26. How many comparisons are needed to construct the BST on the original array?

A. 5
B. 4
C. 7
D. 10
Answer: _________
Question 85:

Binary Insertion sort is an online sorting algorithm.

A. True
B. False
Answer: _________
Question 86:

Which of the following sorting algorithms is used along with quick sort to sort the sub arrays?

A. Merge sort
B. Shell sort
C. Insertion sort
D. Bubble sort
Answer: _________
Question 87:

What is the auxiliary space requirement of Tim sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 88:

What is the best case time complexity of strand sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(n 2 log n)
Answer: _________
Question 89:

Which of the following is not an adaptive sorting algorithm?

A. insertion sort
B. strand sort
C. stooge sort
D. bubble sort
Answer: _________
Question 90:

Which of the following is true for the LSD radix sort?

A. works best for variable length strings
B. accesses memory randomly
C. inner loop has less instructions
D. sorts the keys in left-to-right order
Answer: _________
Question 91:

What is the worst case time complexity of Tim sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 92:

Cocktail sort is a variation of . . . . . . . .

A. Bubble sort
B. Selection sort
C. Insertion sort
D. Gnome sort
Answer: _________
Question 93:

Which of the following sorting algorithm is used by C++ internally?

A. quicksort
B. merge sort
C. introsort
D. heap sort
Answer: _________
Question 94:

Which of the following sorting algorithm uses the method of insertion?

A. selection sort
B. quick sort
C. bubble sort
D. cycle sort
Answer: _________
Question 95:

If Hibbard increments (h1 = 1, h2 = 3, h3 = 7, ..., hk = 2 k - 1) are used in a Shell sort implementation, then the best case time complexity will be . . . . . . . .

A. O(nlogn)
B. O(n)
C. O(n 2 )
D. O(logn)
Answer: _________
Question 96:

Which sorting algorithm is most appropriate for sorting linked lists?

A. Merge Sort
B. Quick Sort
C. Insertion Sort
D. Heap Sort
Answer: _________
Question 97:

Which sorting algorithm can be used to sort a large number of floating-point numbers efficiently?

A. Selection Sort
B. Bubble Sort
C. Counting Sort
D. Radix Sort
Answer: _________
Question 98:

Which sorting algorithm is known for its efficiency with partially sorted data?

A. Quick Sort
B. Merge Sort
C. Insertion Sort
D. Heap Sort
Answer: _________
Question 99:

What is the best-case time complexity of Quick Sort?

A. O(n 2 )
B. O(n log n)
C. O(log n)
D. O(n 2 )
Answer: _________
Question 100:

Which sorting algorithm works by repeatedly finding the minimum element from the unsorted portion?

A. Merge Sort
B. Insertion Sort
C. Selection Sort
D. Bubble Sort
Answer: _________
Question 101:

What is the space complexity of Radix Sort?

A. O(n)
B. O(k)
C. O(1)
D. O(n + k)
Answer: _________
Question 102:

In which situation is Merge Sort particularly useful?

A. When stable sorting is required and the data is large.
B. When space is limited.
C. When the data is almost sorted.
D. When the data set is very small.
Answer: _________
Question 103:

Which sorting algorithm has a time complexity of O(n log n) in the worst case and is not stable?

A. Counting Sort
B. Heap Sort
C. Merge Sort
D. Quick Sort
Answer: _________
Question 104:

What is the main drawback of Bubble Sort?

A. It is not a stable sort.
B. It requires additional memory.
C. It is inefficient for large datasets.
D. It cannot sort linked lists.
Answer: _________
Question 105:

Which sorting algorithm is best for sorting strings of fixed length?

A. Insertion Sort
B. Radix Sort
C. Quick Sort
D. Insertion Sort
Answer: _________
Question 106:

What is the recurrence relation for stooge sort?

A. T(n) = 2T(2/3n) + O(n)
B. T(n) = 2T(2/3n) + O(1)
C. T(n) = 3T(2/3n) + O(n)
D. T(n) = 3T(2/3n) + O(1)
Answer: _________
Question 107:

Apply Quick sort on a given sequence 7 11 14 6 9 4 3 12. What is the sequence after first phase, pivot is first element?

A. 6 4 3 7 11 9 14 12
B. 6 3 4 7 9 14 11 12
C. 7 6 14 11 9 4 3 12
D. 7 6 4 3 9 14 11 12
Answer: _________
Question 108:

What is the average case time complexity of cycle sort?

A. O(n 2 )
B. O(n log n)
C. O(log n)
D. O(n)
Answer: _________
Question 109:

Which of the following sorting algorithm is in-place?

A. Merge sort
B. Cycle sort
C. Counting sort
D. Radix sort
E. intro sort
F. merge sort
G. counting sort
H. radix sort
Answer: _________
Question 110:

What is the worst case time complexity of odd-even sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 111:

The worst case running time of shell sort, using Shell's increments is?

A. O(N)
B. O(N log N)
C. O(log N)
D. O(N 2 )
Answer: _________
Question 112:

Which of the following sorting algorithms can be considered as improvement to the binary tree sort?

A. Heap sort
B. Quick sort
C. Selection sort
D. Insertion sort
Answer: _________
Question 113:

Which of the following options contain the correct feature of an insertion sort algorithm?

A. anti-adaptive
B. dependable
C. stable, not in-place
D. stable, adaptive
Answer: _________
Question 114:

What is the auxiliary space requirement of cycle sort?

A. O(n)
B. O(1)
C. O(log n)
D. O(n log n)
Answer: _________
Question 115:

Records R1, R2, R3,.. RN with keys K1, K2, K3,.. KN are said to be h-ordered, if . . . . . . . .

A. Ki <= Ki+h for 1<= i*h <= N
B. Kh <= Ki+h for 1<= i <= N
C. Ki <= Kh for 1<= i <= h
D. Ki <= Ki+h for 1<= i <= N-h
Answer: _________
Question 116:

Which of the following sorting algorithm is not in place?

A. quick sort
B. bead sort
C. cycle sort
D. heap sort
E. quick sort
F. strand sort
G. cycle sort
H. heap sort
I. insertion sort
J. quick sort
K. tree sort
L. gnome sort
M. library sort
N. quick sort sort
O. heap sort
P. gnome sort
Answer: _________
Question 117:

Which of the following sorting algorithm is in place?

A. recursive bubble sort
B. merge sort
C. radix sort
D. counting sort
Answer: _________
Question 118:

MSD radix sort should be preferred over LSD radix sort when we have to maintain the original relative order.

A. True
B. False
Answer: _________
Question 119:

Which of the following sorting algorithm is a constituent of tim sort?

A. selection sort
B. quick sort
C. merge sort
D. heap sort
Answer: _________
Question 120:

Randomized quick sort is a stable sort.

A. true
B. false
Answer: _________
Question 121:

Introsort sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 122:

Which of the following methods is the most effective for picking the pivot element?

A. first element
B. last element
C. median-of-three partitioning
D. random element
Answer: _________
Question 123:

What is the average number of comparisons used to heap sort a random permutation of N distinct items?

A. 2N log N-O(N)
B. 2N log N-O(N log N)
C. 2N log N-O(N log log N)
D. 2N log N-O(log N)
Answer: _________
Question 124:

Which of the following sorting algorithm is NOT stable?

A. Quick sort
B. Cocktail sort
C. Bubble sort
D. Merge sort
E. Introsort
F. Brick sort
G. Bubble sort
H. Merge sort
Answer: _________
Question 125:

On which algorithm is heap sort based on?

A. Fibonacci heap
B. Binary tree
C. Priority queue
D. FIFO
Answer: _________
Question 126:

Which of the following is not true about QuickSort?

A. in-place algorithm
B. pivot position can be changed
C. adaptive sorting algorithm
D. can be implemented as a stable sort
Answer: _________
Question 127:

What is the average case time complexity of tree sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 128:

Which of the following is an advantage of recursive insertion sort over its iterative version?

A. it has better time complexity
B. it has better space complexity
C. it is easy to implement
D. it has no significant advantage
Answer: _________
Question 129:

Consider the following statements related to the binary tree sort. I. Element can be added gradually as they become available II. It needs extra memory space

A. Statement I is true but Statement II is false
B. Both Statement I and Statement II are false
C. Both Statement I and Statement II are true
D. Statement II is true but Statement I is false
Answer: _________
Question 130:

What is the average time complexity of Tim sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 131:

What is a randomized QuickSort?

A. The leftmost element is chosen as the pivot
B. The rightmost element is chosen as the pivot
C. Any element in the array is chosen as the pivot
D. A random number is generated which is used as the pivot
Answer: _________
Question 132:

Which of the following is not an exchange sort?

A. Bubble Sort
B. Quick Sort
C. Partition-exchange Sort
D. Insertion Sort
Answer: _________
Question 133:

Stooge sort is a comparison based sorting algorithm.

A. true
B. false
Answer: _________
Question 134:

Bead sort is only applicable to positive integers.

A. true
B. false
Answer: _________
Question 135:

Which of the following sorting algorithm has the same time complexity in every case?

A. stooge sort
B. strand sort
C. quick sort
D. bubble sort
Answer: _________
Question 136:

What is the average case time complexity of bogosort?

A. O(n 2 )
B. O(n*n!)
C. O(infinity)
D. O(n log n)
Answer: _________
Question 137:

Which of the following algorithm takes linear time for sorting?

A. pigeonhole sort
B. heap sort
C. comb sort
D. cycle sort
Answer: _________
Question 138:

What is the cut-off for switching from quick sort to heap sort in the implementation of introsort?

A. 16
B. n 2
C. n log(n)
D. 2 log (n)
Answer: _________
Question 139:

What is the auxiliary space complexity of recursive insertion sort?

A. O(n)
B. O(1)
C. O(n log n)
D. O(n 2 )
Answer: _________
Question 140:

What is the average case time complexity of gnome sort?

A. O(n)
B. O(n 2 )
C. O(n log n)
D. O(log n)
Answer: _________
Question 141:

What is the disadvantage of counting sort?

A. counting sort has large time complexity
B. counting sort has large space complexity
C. counting sort is not a comparison based sorting technique
D. counting sort cannot be used for array with non integer elements
Answer: _________
Question 142:

Auxiliary space used by gnome sort is . . . . . . . .

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 143:

What is the purpose of using randomized quick sort over standard quick sort?

A. so as to avoid worst case time complexity
B. so as to avoid worst case space complexity
C. to improve accuracy of output
D. to improve average case time complexity
Answer: _________
Question 144:

What is the purpose of using a median of three quick sort over standard quick sort?

A. so as to avoid worst case time complexity
B. so as to avoid worst case space complexity
C. to improve accuracy of output
D. to improve average case time complexity
Answer: _________
Question 145:

Bucket sort is a generalization of which of the following sort?

A. LSD radix sort
B. Pigeonhole sort
C. Counting sort
D. MSD radix sort
Answer: _________
Question 146:

What is the worst case time complexity of cocktail sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 147:

What will be the recurrence relation of the code of recursive bubble sort?

A. T(n) = 2T(n/2) + n
B. T(n) = 2T(n/2) + c
C. T(n) = T(n-1) + n
D. T(n) = T(n-1) + c
Answer: _________
Question 148:

Which of the following sorting algorithm is not a constituent of introsort?

A. selection sort
B. quicksort
C. insertion sort
D. heap sort
Answer: _________
Question 149:

How many write operations will be required to sort the array arr={2, 4, 3, 5, 1} using cycle sort?

A. 4
B. 5
C. 6
D. 3
Answer: _________
Question 150:

What is the auxiliary space requirement of counting sort?

A. O(1)
B. O(n)
C. O(log n)
D. O(n+k) k=range of input
Answer: _________
Question 151:

The initial gap between two elements being compared . . . . . . . .

A. is equal to number of elements in the array
B. is equal to 1.3
C. depends on the number of iterations
D. depends on the compiler being used
Answer: _________
Question 152:

What will be the pivot for the array arr={8, 2, 4, 9} for making the first partition when a median of three quick sort is implemented?

A. 8
B. 2
C. 4
D. 9
Answer: _________
Question 153:

How many elements can be sorted in O(logn) time using Heap sort?

A. O(1)
B. O(n/2)
C. O(logn/log(logn))
D. O(logn)
Answer: _________
Question 154:

What is the auxiliary space complexity of tree sort?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 155:

What is the best case time complexity of cycle sort?

A. O(n 2 )
B. O(n)
C. O(n log n)
D. O(1)
Answer: _________
Question 156:

Which of the following algorithm is best suited for the case where swap operation is expensive?

A. bubble sort
B. cycle sort
C. cocktail sort
D. merge sort
Answer: _________
Question 157:

What is the space complexity of pigeonhole sort (k=range of input)?

A. O(n*k)
B. O(n)
C. O(k)
D. O(n+k)
Answer: _________
Question 158:

Bottom up merge sort is a stable sort.

A. true
B. false
Answer: _________
Question 159:

What is the average case time complexity of odd-even sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 160:

Which of the following sorting algorithm does not use recursion?

A. bottom up merge sort
B. merge sort
C. heap sort
D. quick sort
Answer: _________
Question 161:

Which of the following is a variation of bubble sort?

A. selection sort
B. odd even sort
C. cocktail sort
D. stupid sort
Answer: _________
Question 162:

The worst case time complexity of insertion sort is O(n 2 ). What will be the worst case time complexity of insertion sort if the correct position for inserting element is calculated using binary search?

A. O(nlogn)
B. O(n 2 )
C. O(n)
D. O(logn)
Answer: _________
Question 163:

Which of the following is not necessarily a stable sorting algorithm?

A. bucket sort
B. counting sort
C. merge sort
D. pigeonhole sort
Answer: _________
Question 164:

What is the average case complexity of bubble sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 165:

Comb sort is an improved version of . . . . . . . .

A. Selection sort
B. Bubble sort
C. Insertion sort
D. Merge sort
Answer: _________
Question 166:

Quick sort uses which of the following algorithm to implement sorting?

A. backtracking
B. greedy algorithm
C. divide and conquer
D. dynamic programming
Answer: _________
Question 167:

What is the worst case time complexity of cube sort?

A. O(n)
B. O(log n)
C. O(n log n)
D. O(n2)
Answer: _________
Question 168:

Merge sort can be implemented using O(1) auxiliary space.

A. true
B. false
Answer: _________
Question 169:

What will be the best case time complexity of merge sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 170:

Quick sort uses join operation rather than merge operation.

A. true
B. false
Answer: _________
Question 171:

What is the typical running time of a heap sort algorithm?

A. O(N)
B. O(N log N)
C. O(log N)
D. O(N 2 )
Answer: _________
Question 172:

What is the worst case complexity of QuickSort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 173:

What is its wort case time complexity of Heap sort?

A. O(nlogn)
B. O(n 2 logn)
C. O(n 2 )
D. O(n 3 )
Answer: _________
Question 174:

What is the worst case time complexity of strand sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(n 2 log n)
Answer: _________
Question 175:

Which of the following is the most suitable definition of radix sort?

A. It is a non comparison based integer sort
B. It is a comparison based integer sort
C. It is a non comparison based non integer sort
D. It is a comparison based non integer sort
Answer: _________
Question 176:

What is the auxiliary space complexity of a median of three quick sort?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 177:

Sleep sort can be preferred over which of the following sorting algorithms for large number of input elements?

A. Quick sort
B. Bubble sort
C. Selection sort
D. No sorting algorithm is preferred
Answer: _________
Question 178:

What is the auxiliary space requirement of introsort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 179:

An array that is first 7-sorted, then 5-sorted becomes . . . . . . . .

A. 7-ordered
B. 5-ordered
C. both 2-ordered and 5-ordered
D. both 7-ordered and 5-ordered
Answer: _________
Question 180:

How many recursive statements are used in the algorithm of stooge sort?

A. 0
B. 1
C. 2
D. 3
Answer: _________
Question 181:

In how many comparisons does the array arr={1, 4, 2, 3, 5} gets sorted if we use sleep sort?

A. 5
B. 3
C. 1
D. 0
Answer: _________
Question 182:

What is the worst case time complexity of introsort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 183:

Which of the following is correct with regard to insertion sort?

A. insertion sort is stable and it sorts In-place
B. insertion sort is unstable and it sorts In-place
C. insertion sort is stable and it does not sort In-place
D. insertion sort is unstable and it does not sort In-place
Answer: _________
Question 184:

What is the space complexity of in place merge sort?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 185:

Sleep sort works by . . . . . . . .

A. making elements to sleep for a time that is proportional to their magnitude
B. making elements to sleep for a time that is inversely proportional to their magnitude
C. partitioning the input array
D. dividing the value of input elements
Answer: _________
Question 186:

Heap sort is faster than Shell sort.

A. true
B. false
Answer: _________
Question 187:

Statement 1: In insertion sort, after m passes through the array, the first m elements are in sorted order. Statement 2: And these elements are the m smallest elements in the array.

A. Both the statements are true
B. Statement 1 is true but statement 2 is false
C. Statement 1 is false but statement 2 is true
D. Both the statements are false
Answer: _________
Question 188:

What is the average time complexity of randomized quick sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 189:

Bead sort is also known as . . . . . . . .

A. gravity sort
B. strand sort
C. abacus sort
D. counting sort
Answer: _________
Question 190:

What is the average case complexity of selection sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 191:

Which of the following is not an example of non comparison sort?

A. bubble sort
B. counting sort
C. radix sort
D. bucket sort
Answer: _________
Question 192:

Which of the following algorithm implementations is similar to that of an insertion sort?

A. Binary heap
B. Quick sort
C. Merge sort
D. Radix sort
Answer: _________
Question 193:

Which of the following is not a stable sorting algorithm?

A. Quick sort
B. Cocktail sort
C. Bubble sort
D. Merge sort
Answer: _________
Question 194:

Which of the following sorting algorithm is only applicable to positive integers?

A. quick sort
B. heap sort
C. bead sort
D. strand sort
Answer: _________
Question 195:

In which case will tim sort will work as an insertion sort?

A. when no. of elements are less than 64
B. when no. of elements are greater than 64
C. when no. of elements are less than size of run
D. when no. of elements are less than 32
Answer: _________
Question 196:

In a computational complexity theory, a problem with decision making is said to be NP-complete when it is both in NP and NP-hard. What does NP mean?

A. Non Polynomial time
B. Non-deterministic Probabilistic
C. Non-deterministic Polynomial time
D. Non Probabilistic time
Answer: _________
Question 197:

The complexity of which of the following sorting algorithms remains to be the same in its best, average and worst case?

A. quick sort
B. insertion sort
C. counting sort
D. gnome sort
Answer: _________
Question 198:

In the following scenarios, when will you use selection sort?

A. The input is already sorted
B. A large file has to be sorted
C. Large values need to be sorted with small keys
D. Small values need to be sorted with large keys
Answer: _________
Question 199:

What is the first step in the algorithm of stooge sort(after base case)?

A. apply stooge sort on first 2/3 elements of array
B. apply stooge sort on last 2/3 elements of array
C. apply stooge sort on first 1/3 elements of array
D. compare first and last element of the array
Answer: _________
Question 200:

The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array with improvised version?

A. 4
B. 2
C. 1
D. 0
Answer: _________
Question 201:

The given array is arr = {1, 2, 4, 3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array?

A. 4
B. 2
C. 1
D. 0
Answer: _________
Question 202:

What will be the order of elements of the array arr = {23, 67, 143, 654, 43} after first iteration of MSD sort is complete?

A. 23, 43, 67, 143, 654
B. 23, 67, 43, 143, 654
C. 23, 67, 143, 654, 43
D. 23, 143, 43, 654, 67
Answer: _________
Question 203:

Which of the following sorting algorithm is most closely related to the OS?

A. gnome sort
B. sleep sort
C. radix sort
D. bogo sort
Answer: _________
Question 204:

Why is Shell sort called as a generalization of Insertion sort?

A. Shell sort allows an exchange of far items whereas insertion sort moves elements by one position
B. Improved lower bound analysis
C. Insertion is more efficient than any other algorithms
D. Shell sort performs internal sorting
Answer: _________
Question 205:

Which of the following is an alternate name of MSD radix sort?

A. bottom up radix sort
B. top down radix sort
C. forward radix sort
D. backward radix sort
Answer: _________
Question 206:

Given an array of the following elements 81, 94, 11, 96, 12, 35, 17, 95, 28, 58, 41, 75, 15. What will be the sorted order after 5-sort?

A. 11,12,15,17,28,35,41,58,75,81,94,95,96
B. 28,12,11,35,41,58,17,94,75,81,96,95,15
C. 35,17,11,28,12,41,75,15,96,58,81,94,95
D. 12,11,15,17,81,94,85,96,28,35,41,58,75
Answer: _________
Question 207:

What is the cut-off for switching from quick sort to insertion sort in the implementation of introsort?

A. 4
B. 8
C. 16
D. 32
Answer: _________
Question 208:

Auxiliary space requirement of sleep sort is . . . . . . . .

A. O(n)
B. O(1)
C. O(max(input))
D. O(log n)
Answer: _________
Question 209:

What is the best case complexity of QuickSort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 210:

What is the best case time complexity of gnome sort?

A. O(n)
B. O(n 2 )
C. O(n log n)
D. O(log n)
Answer: _________
Question 211:

Which one of the following sorting algorithm is best suited to sort an array of 1 million elements?

A. Bubble sort
B. Insertion sort
C. Merge sort
D. Quick sort
Answer: _________
Question 212:

Which of the following is an advantage of recursive bubble sort over its iterative version?

A. it has better time complexity
B. it has better space complexity
C. it is easy to implement
D. it has no significant advantage
Answer: _________
Question 213:

It is not possible to implement counting sort when any of the input element has negative value.

A. True
B. False
Answer: _________
Question 214:

Which of the following is the distribution sort?

A. Heap sort
B. Smooth sort
C. Quick sort
D. LSD radix sort
Answer: _________
Question 215:

Which of the following sorting algorithm will be preferred when the size of partition is between 16 and 2 log(n) while implementing introsort?

A. quick sort
B. insertion sort
C. heap sort
D. merge sort
Answer: _________
Question 216:

What is the worst case analysis of Shell sort using Sedgewick's increments?

A. O(N 2 )
B. O(N 3/2 )
C. O(N 4/3 )
D. O(N 5/4 )
Answer: _________
Question 217:

What characteristic of TimSort helps it perform well on real-world data?

A. It is a hybrid sorting algorithm combining Merge Sort and Insertion Sort.
B. It is a stable sort.
C. It uses less memory.
D. It is efficient for small arrays.
Answer: _________
Question 218:

Which sorting algorithm performs the fewest number of swaps on average?

A. Heap Sort
B. Quick Sort
C. Selection Sort
D. Insertion Sort
Answer: _________
Question 219:

In which scenario does the Heap Sort algorithm perform best?

A. When the data is partially sorted.
B. When the data is sorted in reverse.
C. When the data is unsorted.
D. When the data is very small.
Answer: _________
Question 220:

What type of sorting algorithm is Bucket Sort?

A. Hybrid
B. Non-comparison-based
C. Stable sort
D. Hybrid
Answer: _________
Question 221:

Which sorting algorithm does not work efficiently for arrays with large ranges of integer keys?

A. Quick Sort
B. Merge Sort
C. Counting Sort
D. Radix Sort
Answer: _________
Question 222:

Shell sort is more efficient than insertion sort if the length of input arrays is small.

A. True
B. False
Answer: _________
Question 223:

The given array is arr={7, 4, 5, 8, 1, 2}. The number of iterations required to sort the array using comb sort and bubble sort respectively will be . . . . . . . .

A. 7 and 8
B. 5 and 6
C. 5 and 5
D. 4 and 5
Answer: _________
Question 224:

What is the auxiliary space complexity of merge sort?

A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
Answer: _________
Question 225:

What is the auxiliary space requirement of permutation sort?

A. O(n)
B. O(1)
C. O(log n)
D. O(n log n)
Answer: _________
Question 226:

Which of the following is an example of parallel sorting technique?

A. bogo sort
B. sleep sort
C. cube sort
D. merge sort
Answer: _________
Question 227:

In insertion sort, the average number of comparisons required to place the 7 th element into its correct position is . . . . . . . .

A. 9
B. 4
C. 7
D. 14
Answer: _________
Question 228:

Which of the following is not true about library sort?

A. it uses binary search and insertion sort in its implementation
B. gaps are created between successive elements in order to ensure faster insertion
C. array needs to be re balanced after every insertion
D. it is an in place sorting algorithm
Answer: _________
Question 229:

Cycle sort is an adaptive sorting algorithm.

A. true
B. false
Answer: _________
Question 230:

In binary tree sort, we first construct the BST and then we perform . . . . . . . . traversal to get the sorted order.

A. inorder
B. postorder
C. preorder
D. level order
Answer: _________
Question 231:

Which one of the following sorting algorithm requires recursion?

A. pigeonhole sort
B. strand sort
C. insertion sort
D. counting sort
Answer: _________
Question 232:

How many comparisons will be required to sort the array arr={5, 4, 7, 1, 9} using bead sort?

A. 5
B. 4
C. 6
D. 0
Answer: _________
Question 233:

What is the other name for a shell sort algorithm?

A. Diminishing increment sort
B. Diminishing decrement sort
C. Insertion sort
D. Selection sort
Answer: _________
Question 234:

Which of the following sorting algorithm is stable?

A. Selection sort
B. Quick sort
C. Bubble sort
D. Heap sort
Answer: _________
Question 235:

Which of the following statement is not a stable sorting algorithm?

A. LSD radix sort
B. MSD radix sort
C. Counting sort
D. Pigeonhole sort
Answer: _________
Question 236:

The essential part of Heap sort is construction of max-heap. Consider the tree shown below, the node 24 violates the max-heap property. Once heapify procedure is applied to it, which position will it be in?

A. 4
B. 5
C. 8
D. 9
Answer: _________
Question 237:

Brick sort uses which of the following methods for sorting the input?

A. selection
B. partitioning
C. merging
D. exchanging
Answer: _________
Question 238:

What is the average time complexity of bead sort (S = sum of input elements)?

A. O(n)
B. O(S)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 239:

Which of the following is an advantage of binary insertion sort over its standard version?

A. it has better time complexity
B. it has better space complexity
C. it makes less number of comparisons
D. it has no significant advantage
Answer: _________
Question 240:

Sleep sort does gives a correct output when . . . . . . . .

A. any input element is negative
B. input array is reverse sorted
C. any input element is positive
D. when there is a very small number to the left of very large number
Answer: _________
Question 241:

Which of the following sorting algorithm is not stable . . . . . . . .

A. insertion sort
B. bubble sort
C. merge sort
D. bogosort
Answer: _________
Question 242:

Which of the following sorting algorithm is not in-place?

A. insertion sort
B. tim sort
C. quick sort
D. intro sort
Answer: _________
Question 243:

Binary insertion sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 244:

What is the running time of an insertion sort algorithm if the input is pre-sorted?

A. O(N 2 )
B. O(N log N)
C. O(N)
D. O(M log N)
Answer: _________
Question 245:

What is the space complexity of stooge sort?

A. O(n)
B. O(1)
C. O(log n)
D. O(n log n)
Answer: _________
Question 246:

What is the worst case time complexity of randomized quicksort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(n 2 log n)
Answer: _________
Question 247:

What is the time taken to copy elements to and from two arrays created for deletion?

A. O(N)
B. O(N log N)
C. O(log N)
D. O(N 2 )
Answer: _________
Question 248:

Which of the following is not true about bucket sort?

A. It is a non comparison based integer sort
B. It is a distribution sort
C. It can also be considered as comparison based sort
D. It is in place sorting algorithm
Answer: _________
Question 249:

What is the worst case time complexity of permutation sort?

A. O(n 2 )
B. O(n*n!)
C. O(infinity)
D. O(n log n)
Answer: _________
Question 250:

Pigeonhole sort is a stable sorting algorithm.

A. true
B. false
Answer: _________
Question 251:

What is the average number of inversions in an array of N distinct numbers?

A. N(N-1)/4
B. N(N+1)/2
C. N(N-1)/2
D. N(N-1)/3
Answer: _________
Question 252:

Cocktail sort uses which of the following methods for sorting the input?

A. selection
B. partitioning
C. merging
D. exchanging
Answer: _________
Question 253:

Which of the following is Python's standard sorting algorithm?

A. quick sort
B. introsort
C. merge sort
D. tim sort
Answer: _________
Question 254:

The given array is arr = {2, 3, 4, 1, 6}. What are the pivots that are returned as a result of subsequent partitioning?

A. 1 and 3
B. 3 and 1
C. 2 and 6
D. 6 and 2
Answer: _________
Question 255:

What is the average case running time of an insertion sort algorithm?

A. O(N)
B. O(N log N)
C. O(log N)
D. O(N 2 )
Answer: _________
Question 256:

Recursive bubble sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 257:

Insertion sort is an example of an incremental algorithm.

A. True
B. False
Answer: _________
Question 258:

Who invented the shell sort algorithm?

A. John Von Neumann
B. Donald Shell
C. Tony Hoare
D. Alan Shell
Answer: _________
Question 259:

Which of the following method is used for sorting in merge sort?

A. partitioning
B. merging
C. exchanging
D. selection
Answer: _________
Question 260:

How many arrays are required to perform deletion operation in a heap?

A. 1
B. 2
C. 3
D. 4
Answer: _________
Question 261:

What is the average case time complexity of recursive insertion sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 262:

How many comparisons will be made in the worst case when an array of size n will be sorted by using a binary insertion sort algorithm?

A. n
B. 1
C. log n
D. n log n
Answer: _________
Question 263:

In which of the following case stooge sort is most efficient (in terms of time complexity)?

A. when input array is already sorted
B. when input array is reverse sorted
C. when input array is large
D. it has the same time complexity in any case
Answer: _________
Question 264:

Recursive insertion sort is a comparison based sort.

A. True
B. False
Answer: _________
Question 265:

Which of the following real time examples is based on insertion sort?

A. arranging a pack of playing cards
B. database scenarios and distributes scenarios
C. arranging books on a library shelf
D. real-time systems
Answer: _________
Question 266:

Consider the following heap after buildheap phase. What will be its corresponding array?

A. 26,53,41,97,58,59,31
B. 26,31,41,53,58,59,97
C. 26,41,53,97,31,58,59
D. 97,53,59,26,41,58,31
Answer: _________
Question 267:

Bottom up merge sort uses recursion.

A. true
B. false
Answer: _________
Question 268:

Cocktail sort is also known as . . . . . . . .

A. bidirectional sort
B. bubble sort
C. brick sort
D. ripple sort
Answer: _________
Question 269:

What is the average running time of a quick sort algorithm?

A. O(N 2 )
B. O(N)
C. O(N log N)
D. O(log N)
Answer: _________
Question 270:

Sleep sort code cannot compile online because . . . . . . . .

A. it has very high time complexity
B. it has very high space complexity
C. it requires multithreading process
D. online compilers are not efficient
Answer: _________
Question 271:

Which of the following sorting algorithm uses a binary search tree?

A. radix sort
B. tree sort
C. odd-even sort
D. bead sort
Answer: _________
Question 272:

What is the worst case time complexity of a quick sort algorithm?

A. O(N)
B. O(N log N)
C. O(N 2 )
D. O(log N)
Answer: _________
Question 273:

What is the auxiliary space complexity of recursive bubble sort?

A. O(n)
B. O(1)
C. O(n log n)
D. O(n 2 )
Answer: _________
Question 274:

In place merge sort has same time complexity as standard merge sort.

A. true
B. false
Answer: _________
Question 275:

Odd-even sort is also known as . . . . . . . .

A. stupid sort
B. smart sort
C. brick sort
D. bogo sort
Answer: _________
Question 276:

In what position does the array for heap sort contains data?

A. 0
B. 1
C. -1
D. anywhere in the array
Answer: _________
Question 277:

Strand sort is most efficient for data stored in?

A. linked list
B. arrays
C. trees
D. graphs
Answer: _________
Question 278:

What is the average time complexity of strand sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(n 2 log n)
Answer: _________
Question 279:

What is the auxiliary space complexity of binary insertion sort?

A. O(n)
B. O(1)
C. O(n log n)
D. O(n 2 )
Answer: _________
Question 280:

Bubble sort is an adaptive sorting algorithm.

A. true
B. false
Answer: _________
Question 281:

How many comparisons will be made to sort the array arr={1, 5, 3, 8, 2} using pigeonhole sort?

A. 5
B. 7
C. 9
D. 0
Answer: _________
Question 282:

The auxiliary array used in pigeonhole sorting is called . . . . . . . .

A. bucket
B. pigeon
C. hole
D. pigeonhole
Answer: _________
Question 283:

Odd-even sort is a variation of . . . . . . . .

A. Bubble sort
B. Selection sort
C. Insertion sort
D. Gnome sort
Answer: _________
Question 284:

Bubble sort performs better as compared to cocktail sort.

A. True
B. False
Answer: _________
Question 285:

Which of the following is an advantage of cycle sort?

A. it can sort large arrays efficiently
B. it has a low time complexity
C. it requires minimal write operations
D. it is an adaptive sorting algorithm
Answer: _________
Question 286:

Consider the Quick sort algorithm which sorts elements in ascending order using the first element as pivot. Then which of the following input sequence will require a maximum number of comparisons when this algorithm is applied on it?

A. 22 25 56 67 89
B. 52 25 76 67 89
C. 22 25 76 67 50
D. 52 25 89 67 76
Answer: _________
Question 287:

Sleep sort is an in-place sorting technique.

A. True
B. False
Answer: _________
Question 288:

Which of the following sorting techniques is stable?

A. quick sort
B. counting sort
C. heap sort
D. selection sort
Answer: _________
Question 289:

Which of the following sorting algorithm makes use of merge sort?

A. tim sort
B. intro sort
C. bogo sort
D. quick sort
Answer: _________
Question 290:

Merge sort uses which of the following algorithm to implement sorting?

A. backtracking
B. greedy algorithm
C. divide and conquer
D. dynamic programming
Answer: _________
Question 291:

What is the average time complexity of bottom up merge sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 292:

Which of the following is a combination of LSD and MSD radix sorts?

A. Forward radix sort
B. 3-way radix quick sort
C. Trie base radix sort
D. Flash sort
Answer: _________
Question 293:

How many comparisons will be made to sort the array arr={1, 5, 3, 8, 2} using counting sort?

A. 5
B. 7
C. 9
D. 0
Answer: _________
Question 294:

Shell sort algorithm is the first algorithm to break the quadratic time barrier.

A. True
B. False
Answer: _________
Question 295:

What is the advantage of pigeonhole sort over merge sort?

A. pigeonhole sort has lesser time complexity when range is comparable to number of input elements
B. pigeonhole sort has lesser space complexity
C. counting sort is not a comparison based sorting technique
D. pigeonhole sort is adaptive
Answer: _________
Question 296:

Which of the following is a variant of insertion sort?

A. selection sort
B. shell sort
C. odd-even sort
D. stupid sort
Answer: _________
Question 297:

The given array is arr = {2, 6, 1}. What are the pivots that are returned as a result of subsequent partitioning?

A. 1 and 6
B. 6 and 1
C. 2 and 6
D. 1
Answer: _________
Question 298:

What are the number of swaps required to sort the array arr={1, 2, 4, 3, 7, 5, 6} using recursive bubble sort?

A. 0
B. 1
C. 2
D. 3
Answer: _________
Question 299:

Bucket sort is an in place sorting algorithm.

A. True
B. False
Answer: _________
Question 300:

Strand sort algorithm used which of the following method for sorting a list?

A. merging
B. selection
C. insertion
D. partitioning
Answer: _________
Question 301:

MSD radix sort is an in place sorting algorithm.

A. True
B. False
Answer: _________
Question 302:

What is the best time complexity of bucket sort (k= number of buckets)?

A. O(n + k)
B. O(n.k)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 303:

What is the advantage of selection sort over other sorting techniques?

A. It is faster than any other sorting technique
B. It is scalable
C. It works best for inputs which are already sorted
D. It requires no additional storage space
Answer: _________
Question 304:

What is the best case time complexity of the binary tree sort?

A. O(n)
B. O(nlogn)
C. O(n 2 )
D. O(logn)
Answer: _________
Question 305:

What is the advantage of library sort over insertion sort?

A. Library sort has a better average time complexity
B. Library sort has a better space complexity
C. Library sort has better best case time complexity
D. Library has better worst case time complexity
Answer: _________
Question 306:

What is the worst case complexity of bubble sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 307:

What is the auxiliary space complexity of randomized quick sort?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 308:

What is the best case time complexity of recursive bubble sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 309:

On how many increment sequences does the worst case analysis of shell sort depends?

A. one
B. two
C. three
D. four
Answer: _________
Question 310:

What is the advantage of radix sort over quick sort?

A. radix sort performs better than quick sort when we have log n bits for every digit
B. radix sort has lesser space complexity
C. radix sort is not a comparison based sorting technique
D. radix sort has better cache performance than quick sort
Answer: _________
Question 311:

Binary tree sort is an in-place sorting algorithm.

A. True
B. False
Answer: _________
Question 312:

In which of the following case strand sort is most efficient?

A. when input array is already sorted
B. when input array is reverse sorted
C. when input array is large
D. when input array is has randomly spread elements
Answer: _________
Question 313:

What is the best case time complexity of cube sort?

A. O(n 2 )
B. O(n)
C. O(n log n)
D. O(1)
Answer: _________
Question 314:

Binary search can be used in an insertion sort algorithm to reduce the number of comparisons.

A. True
B. False
Answer: _________
Question 315:

What is the worst case time complexity of gnome sort?

A. O(n)
B. O(n 2 )
C. O(n log n)
D. O(log n)
Answer: _________
Question 316:

What is the worst case time complexity of merge sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 317:

Introsort begins sorting the given array by using which of the following sorting algorithm?

A. selection sort
B. quick sort
C. insertion sort
D. heap sort
Answer: _________
Question 318:

Quick Sort is a . . . . . . . .

A. greedy algorithm
B. divide and conquer algorithm
C. dynamic programming algorithm
D. backtracking algorithm
Answer: _________
Question 319:

What is the worst space complexity of bucket sort (k = number of buckets)?

A. O(n + k)
B. O(n.k)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 320:

How many odd and even phases are required respectively to sort the given array using odd-even sort.arr={3, 2, 3, 8, 5, 6, 2, 1}.

A. 3,3
B. 4,4
C. 3,4
D. 4,3
Answer: _________
Question 321:

How many loops are required to implement gnome sorting algorithm?

A. Single loop
B. 2 nested loops
C. 3 nested loops
D. It does not require any loop
Answer: _________
Question 322:

Which of the following is a disadvantage of cube sort?

A. high memory overhead for small data
B. high memory overhead for any data
C. balancing is slow
D. Iteration is slow
Answer: _________
Question 323:

Which of the following is not an alternative name of permutation sort?

A. stupid sort
B. bogo sort
C. donkey sort
D. monkey sort
Answer: _________
Question 324:

Comb sort is a stable sorting algorithm.

A. True
B. False
Answer: _________
Question 325:

What is the auxiliary space complexity of library sort?

A. O(n)
B. O(1)
C. O(n log n)
D. O(n 2 )
Answer: _________
Question 326:

Choose the correct statement from the following.

A. pigeonhole sort is a comparison based sort
B. any comparison based sorting can be made stable
C. quick sort is not a comparison based sort
D. any comparison based sort requires at least O(n 2 ) time
Answer: _________
Question 327:

What is the average time complexity of the median of three quick sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 328:

Which of the following is not in place sorting algorithm by default?

A. merge sort
B. quick sort
C. heap sort
D. insertion sort
Answer: _________
Question 329:

What is the auxiliary space requirement of cube sort?

A. O(n)
B. O(1)
C. O(log n)
D. O(n log n)
Answer: _________
Question 330:

Auxiliary space requirement of cocktail sort is . . . . . . . .

A. O(n)
B. O(log n)
C. O(1)
D. O(n 2 )
Answer: _________
Question 331:

What is the best case time complexity of library sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 332:

What is the worst case complexity of selection sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 333:

Which of the following is not an alternative name of bogosort?

A. stupid sort
B. permutation sort
C. donkey sort
D. monkey sort
Answer: _________
Question 334:

Stooge sort is a stable sorting algorithm.

A. true
B. false
Answer: _________
Question 335:

Why is insertion sort preferred over other sorting algorithms (like selection sort, bubble sort etc.) for Tim sort implementation?

A. Because insertion sort is faster and adaptive
B. Because insertion sort requires less space
C. Because insertion sort is easy to implement
D. Because insertion sort is easy to understand
Answer: _________
Question 336:

Which of the following sorting algorithms is the fastest for sorting small arrays?

A. Quick sort
B. Shell sort
C. Insertion sort
D. Heap sort
Answer: _________
Question 337:

In what time can a binary heap be built?

A. O(N)
B. O(N log N)
C. O(log N)
D. O(N 2 )
Answer: _________
Question 338:

Which of the following stable sorting algorithm takes the least time when applied to an almost sorted array?

A. Quick sort
B. Insertion sort
C. Selection sort
D. Merge sort
Answer: _________
Question 339:

What is the best case time complexity of tree sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 340:

Permutation sort works by . . . . . . . .

A. generating random permutations of its input
B. partitioning the array
C. dividing the value of input elements
D. generating permutations according to the value of first element of array
Answer: _________
Question 341:

What is the auxiliary space complexity of bead sort?

A. O(n)
B. O(1)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 342:

Pigeonhole sort is an in place sorting algorithm.

A. true
B. false
Answer: _________
Question 343:

Which of the following pair of sorting algorithms are stable?

A. gnome sort and merge sort
B. heap sort and merge sort
C. gnome sort and quick sort
D. merge sort and selection sort
Answer: _________
Question 344:

Auxiliary space requirement of odd-even sort is . . . . . . . .

A. O(n)
B. O(log n)
C. O(1)
D. O(n 2 )
Answer: _________
Question 345:

Which of the following is an example of an unstable sorting algorithm?

A. cycle sort
B. insertion sort
C. bubble sort
D. merge sort
Answer: _________
Question 346:

Bead sort is a comparison based sorting algorithm.

A. true
B. false
Answer: _________
Question 347:

What is the average case time complexity of permutation sort?

A. O(n 2 )
B. O(n*n!)
C. O(infinity)
D. O(n log n)
Answer: _________
Question 348:

Library sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 349:

Which of the following header file is a must to implement sleep sort algorithm?

A. string.h
B. math.hw
C. bios.h
D. windows.h
Answer: _________
Question 350:

Which of the following sorting algorithm uses a binary search?

A. radix sort
B. binary insertion sort
C. odd-even sort
D. bead sort
Answer: _________
Question 351:

Cocktail sort is a comparison based sort.

A. True
B. False
Answer: _________
Question 352:

Cycle sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 353:

What is the best case time complexity randomized quick sort?

A. O(log n)
B. O(n log n)
C. O(n 2 )
D. O(n 2 log n)
Answer: _________
Question 354:

Which of the following data structure is required for the implementation of tree sort?

A. any ordinary tree
B. balanced tree
C. binary search tree
D. unbalanced tree
Answer: _________
Question 355:

What is the average number of comparisons used in a heap sort algorithm?

A. N log N-O(N)
B. O(N log N)-O(N)
C. O(N log N)-1
D. 2N log N + O(N)
Answer: _________
Question 356:

What is the best case time complexity of bogosort?

A. O(n 2 )
B. O(n)
C. O(n log n)
D. O(1)
Answer: _________
Question 357:

The given array is arr = {3, 4, 5, 2, 1}. The number of iterations in bubble sort and selection sort respectively are . . . . . . . .

A. 5 and 4
B. 4 and 5
C. 2 and 4
D. 2 and 5
Answer: _________
Question 358:

In heap sort, after deleting the last minimum element, the array will contain elements in?

A. increasing sorting order
B. tree preorder
C. tree inorder
D. decreasing sorting order
Answer: _________
Question 359:

Median of three quick sort is a stable sort.

A. true
B. false
Answer: _________
Question 360:

Which of the following is not an advantage of tree sort?

A. it has a low space complexity
B. it has good time complexity for balanced BST
C. it is an online sorting algorithm
D. it is stable sorting algorithm
Answer: _________
Question 361:

Which of the following don't affect the time complexity of bucket sort?

A. algorithm implemented for sorting individual buckets
B. number of buckets used
C. distribution of input
D. input values
Answer: _________
Question 362:

Tim sort begins sorting the given array by using which of the following sorting algorithm?

A. selection sort
B. quick sort
C. insertion sort
D. merge sort
Answer: _________
Question 363:

What is the average case time complexity of recursive bubble sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 364:

What is the auxiliary space complexity of standard merge sort?

A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
Answer: _________
Question 365:

What is the median of three techniques in quick sort?

A. quick sort with random partitions
B. quick sort with random choice of pivot
C. choosing median element as pivot
D. choosing median of first, last and middle element as pivot
Answer: _________
Question 366:

Which of the following is not true about radix sort?

A. Radix sort performs better than quick sort when we have log n bits for every digit
B. Radix sort has better cache performance than quick sort
C. Radix sort has higher values of constant factor in asymptotic notation
D. Radix sort takes more space than quick sort
Answer: _________
Question 367:

The Pancake Problems (1975, 1979, 1973) did NOT involve which of the following people?

A. Bill Gates
B. Jacob Goodman
C. Christos Papadimitriou
D. John Goodman
Answer: _________
Question 368:

Insertion sort is an online sorting algorithm.

A. true
B. false
Answer: _________
Question 369:

LSD radix sort is faster than comparison sorts.

A. True
B. False
Answer: _________
Question 370:

What is the average case time complexity of merge sort?

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 371:

Quick Sort can be categorized into which of the following?

A. Brute Force technique
B. Divide and conquer
C. Greedy algorithm
D. Dynamic programming
Answer: _________
Question 372:

Which one of the following is false?

A. Heap sort is an in-place algorithm
B. Heap sort has O(nlogn) average case time complexity
C. Heap sort is stable sort
D. Heap sort is a comparison-based sorting algorithm
Answer: _________
Question 373:

For the best case input, the running time of an insertion sort algorithm is?

A. Linear
B. Binary
C. Quadratic
D. Depends on the input
Answer: _________
Question 374:

Which of the following is true?

A. Shell sort's passes completely sort the elements before going on to the next-smallest gap while Comb sort's passes do not completely sort the elements
B. Shell sort's passes do not completely sort the elements before going on to the next-smallest gap like in Comb sort
C. Comb sort's passes completely sort the elements before going on to the next-smallest gap like in Shell sort
D. Shell sort's passes do not completely sort the elements before going on to the next-smallest gap while Comb sort's passes completely sort the elements
Answer: _________
Question 375:

What is the auxiliary space requirement of bogosort?

A. O(n)
B. O(1)
C. O(log n)
D. O(n log n)
Answer: _________
Question 376:

Strand sort is a stable sorting algorithm.

A. true
B. false
Answer: _________
Question 377:

Auxiliary space used by comb sort is . . . . . . . .

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Answer: _________
Question 378:

Which of the following sorting algorithm requires the use of binary search in their implementation?

A. radix sort
B. library sort
C. odd-even sort
D. bead sort
Answer: _________
Question 379:

What is the best case time complexity Median of three quick sort?

A. O(log n)
B. O(n log n)
C. O(n 2 )
D. O(n 2 log n)
Answer: _________
Question 380:

Tim sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 381:

In C, what are the basic loops required to perform an insertion sort?

A. do- while
B. if else
C. for and while
D. for and if
Answer: _________
Question 382:

Which of the following sorting algorithms is closely related to shell sort?

A. Selection sort
B. Merge sort
C. Insertion sort
D. Bucket sort
Answer: _________
Question 383:

The best case behaviour occurs for quick sort is, if partition splits the array of size n into . . . . . . . .

A. n/2 : (n/2) - 1
B. n/2 : n/3
C. n/4 : 3n/2
D. n/4 : 3n/4
Answer: _________
Question 384:

What is the best case time complexity of recursive insertion sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 385:

How many comparisons will be made to sort the array arr = {1, 5, 3, 8, 2} using MSD radix sort?

A. 5
B. 7
C. 9
D. 0
Answer: _________
Question 386:

What is the best case time complexity of introsort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 387:

Quick sort is a stable sorting algorithm.

A. True
B. False
Answer: _________
Question 388:

Which of the following version of tree sort will have the highest worst case time complexity?

A. using AVL tree as BST
B. using red black tree as BST
C. using splay tree as BST
D. using ordinary BST
Answer: _________
Question 389:

In average case Heap sort is as efficient as the Quick sort.

A. True
B. False
Answer: _________
Question 390:

Quick sort uses which of the following method to implement sorting?

A. partitioning
B. selection
C. exchanging
D. merging
Answer: _________
Question 391:

LSD radix sort is in-place sorting algorithm.

A. False
B. True
Answer: _________
Question 392:

What is the average case time complexity of cube sort?

A. O(n 2 )
B. O(n log n)
C. O(log n)
D. O(n)
Answer: _________
Question 393:

The gap between two elements being compared shrinks by a factor of . . . . . . . . after every iteration.

A. 1.1
B. 1.2
C. 1.3
D. 1.4
Answer: _________
Question 394:

What is the best case time complexity of odd-even sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 395:

What is the worst case time complexity of binary insertion sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 396:

What is the auxiliary space complexity of strand sort?

A. O(n)
B. O(1)
C. O(log n)
D. O(n log n)
Answer: _________
Question 397:

What is the average case complexity of QuickSort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 398:

How many swaps will be required in the worst case to sort an array having n elements using binary insertion sort?

A. n
B. 1
C. n * log n
D. log n
Answer: _________
Question 399:

Cube sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 400:

The given array is arr = {1, 2, 3, 4, 5}. (bubble sort is implemented with a flag variable)The number of iterations in selection sort and bubble sort respectively are . . . . . . . .

A. 5 and 4
B. 1 and 4
C. 0 and 4
D. 4 and 1
Answer: _________
Question 401:

Which of the following sorting algorithm is worst in terms of time complexity?

A. bubble sort
B. selection sort
C. insertion sort
D. stooge sort
Answer: _________
Question 402:

What is the best case complexity of selection sort?

A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n 2 )
Answer: _________
Question 403:

Strand sort is a comparison based sorting algorithm.

A. true
B. false
Answer: _________
Question 404:

Bubble sort is also known as . . . . . . . .

A. stupid sort
B. ship sort
C. sinking sort
D. shell sort
Answer: _________
Question 405:

Which of the following non-comparison sort can also be considered as a comparison based sort?

A. counting sort
B. MSD radix sot
C. bucket sort
D. pigeonhole sort
Answer: _________
Question 406:

What is the time complexity of Bubble Sort in the average case?

A. O(n log n)
B. O(n)
C. O(n 2 )
D. O(n 3 )
Answer: _________
Question 407:

Which sorting algorithm is based on the divide-and-conquer strategy?

A. Insertion Sort
B. Quick Sort
C. Selection Sort
D. Insertion Sort
Answer: _________
Question 408:

What is the space complexity of Merge Sort?

A. O(n 2 )
B. O(1)
C. O(n)
D. O(log n)
Answer: _________
Question 409:

Which sorting algorithm uses a "pivot" element to partition the array into sub-arrays?

A. Merge Sort
B. Heap Sort
C. Counting Sort
D. Quick Sort
Answer: _________
Question 410:

What is the primary advantage of Heap Sort over Quick Sort?

A. It has a guaranteed time complexity of O(n log n) in the worst case.
B. It is stable.
C. It sorts the data in place.
D. It uses less memory than Merge Sort.
Answer: _________
Question 411:

Which sorting algorithm is considered stable?

A. Selection Sort
B. Quick Sort
C. Heap Sort
D. Merge Sort
Answer: _________
Question 412:

In which scenario does Insertion Sort perform best?

A. When the array is in random order.
B. When the array is sorted in reverse order.
C. When the array is already sorted or nearly sorted.
D. When the array has duplicate elements.
Answer: _________
Question 413:

What is the worst-case time complexity of Quick Sort?

A. O(n)
B. O(n 2 )
C. O(log n)
D. O(n)
Answer: _________
Question 414:

Which sorting algorithm is most efficient for sorting small arrays?

A. Counting Sort
B. Heap Sort
C. Insertion Sort
D. Merge Sort
Answer: _________
Question 415:

What is the primary disadvantage of using Counting Sort?

A. It is slower than other sorting algorithms.
B. It is not a stable sort.
C. It does not work with negative numbers.
D. It requires a large amount of memory for large range of input values.
Answer: _________
Question 416:

Consider the Quick sort algorithm in which the partitioning procedure splits elements into two sub-arrays and each sub-array contains at least one-fourth of the elements. Let T(n) be the number of comparisons required to sort array of n elements. Then T(n)<=?

A. T(n) <= 2 T(n/4) + cn
B. T(n) <= T(n/4) + T(3n/4) + cn
C. T(n) <= 2 T(3n/4) + cn
D. T(n) <= T(n/3) + T(3n/4) + cn
Answer: _________
Question 417:

What is the time complexity for a given pancake sort given it undergoes "n" flip operations?

A. O(n)
B. O(n 2 )
C. O(n 3 )
D. O(2n)
Answer: _________
Question 418:

What is the average time complexity of counting sort?

A. O(n)
B. O(n+k) k=range of input
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 419:

What is the best case time complexity of cocktail sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 420:

What is the best case time complexity of permutation sort?

A. O(n 2 )
B. O(n)
C. O(n log n)
D. O(1)
Answer: _________
Question 421:

What is the alternate name of bucket sort?

A. group sort
B. radix sort
C. bin sort
D. uniform sort
Answer: _________
Question 422:

What is the worst case time complexity of tree sort (when implemented with a balanced tree)?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 423:

What is the worst case time complexity of the binary tree sort?

A. O(n)
B. O(nlogn)
C. O(n 2 )
D. O(logn)
Answer: _________
Question 424:

Which of the following sorting algorithms is the fastest?

A. Merge sort
B. Shell sort
C. Insertion sort
D. Quick sort
Answer: _________
Question 425:

In addition to the pancake sorting problem, there is the case of the burnt pancake problem in which we are dealing with pancakes (discs) that are burnt on one side only. In this case it is taken that the burnt side must always end up . . . . . . . .

A. Faced down
B. Faced up
C. It doesn't matter
D. Both sides are burnt
Answer: _________
Question 426:

In which of the following case does a tree sort become adaptive?

A. when implemented with an unbalanced tree
B. when implemented with a balanced tree
C. when implemented with a splay tree as BST
D. when implemented with AVL tree as BST
Answer: _________
Question 427:

Time complexity of sleep sort can be approximated to be . . . . . . . .

A. O(n + max(input))
B. O(n 2 )
C. O(n log n + max(input))
D. O(n log n)
Answer: _________
Question 428:

What is the average time complexity of introsort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 429:

Shell sort is also known as . . . . . . . .

A. diminishing decrement sort
B. diminishing increment sort
C. partition exchange sort
D. diminishing insertion sort
Answer: _________
Question 430:

In which of the following case pigeonhole sort is most efficient?

A. when range of input is less than number of elements
B. when range of input is more than number of elements
C. when range of input is comparable to the number of elements
D. when the given array is almost sorted
Answer: _________
Question 431:

Median of three quick sort is an in place sort.

A. true
B. false
Answer: _________
Question 432:

Which of the following sorting algorithm is best suited if the elements are already sorted?

A. Heap Sort
B. Quick Sort
C. Insertion Sort
D. Merge Sort
Answer: _________
Question 433:

The given array is arr = {1, 2, 4, 3, 5}.The number of iterations required to sort the array using gnome sort will be . . . . . . . .

A. 5
B. 6
C. 7
D. 8
Answer: _________
Question 434:

What is the disadvantage of selection sort?

A. It requires auxiliary memory
B. It is not scalable
C. It can be used for small keys
D. It takes linear time to sort the elements
Answer: _________
Question 435:

Gnome sort uses which of the following method to implement sorting?

A. Merging
B. Partitioning
C. Selection
D. Exchanging
Answer: _________
Question 436:

What is the worst case time complexity of bucket sort (k = number of buckets)?

A. O(n + k)
B. O(n.k)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 437:

Shell sort is an improvement on . . . . . . . .

A. insertion sort
B. selection sort
C. binary tree sort
D. quick sort
Answer: _________
Question 438:

What is the worst case time complexity of tree sort (when implemented with an unbalanced tree)?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 439:

Which of the following algorithm takes non linear time for sorting?

A. counting sort
B. quick sort
C. bucket sort
D. radix sort
Answer: _________
Question 440:

Odd-even sort is a comparison based sort.

A. true
B. false
Answer: _________
Question 441:

Which of the following is good for sorting arrays having less than 100 elements?

A. Quick Sort
B. Selection Sort
C. Merge Sort
D. Insertion Sort
Answer: _________
Question 442:

Which of the following sorting techniques is most efficient if the range of input data is not significantly greater than a number of elements to be sorted?

A. selection sort
B. bubble sort
C. counting sort
D. insertion sort
Answer: _________
Question 443:

Quick sort is a space-optimised version of . . . . . . . .

A. Bubble sort
B. Selection sort
C. Insertion sort
D. Binary tree sort
Answer: _________
Question 444:

What is the average time complexity of MSD radix sort (w= bits required to store each key)?

A. O(n + w)
B. O(n.w)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 445:

What is the average time complexity of stooge sort?

A. O(n 2 )
B. O(n 3 )
C. O(n 2.6 )
D. O(n 2.7 )
Answer: _________
Question 446:

Library sort is a modified version of which of the following sorting algorithm?

A. Bubble sort
B. selection sort
C. insertion sort
D. quick sort
Answer: _________
Question 447:

What is the worst case time complexity of bogosort?

A. O(n 2 )
B. O(n*n!)
C. O(infinity)
D. O(n log n)
Answer: _________
Question 448:

Cube sort is an in place sorting algorithm.

A. true
B. false
Answer: _________
Question 449:

What is the worst case time complexity of LSD radix sort?

A. O(nlogn)
B. O(wn)
C. O(n)
D. O(n + w)
Answer: _________
Question 450:

Why is heap sort preferred over merge sort for introsort implementation?

A. Because heap sort is faster
B. Because heap sort requires less space
C. Because heap sort is easy to implement
D. Because heap sort is easy to understand
Answer: _________
Question 451:

Which of the following combines qualities of MSD radix sort and LSD radix sort?

A. in-place MSD radix sort
B. stable MSD radix sot
C. 3 way radix quick sort
D. forward radix sort
Answer: _________
Question 452:

Randomized quick sort is an in place sort.

A. true
B. false
Answer: _________
Question 453:

In-place merge sort is a stable sort.

A. true
B. false
Answer: _________
Question 454:

Tree sort is an online sorting algorithm.

A. True
B. False
Answer: _________
Question 455:

What will be the number of passes to sort the elements using insertion sort? 14, 12,16, 6, 3, 10

A. 6
B. 5
C. 7
D. 1
Answer: _________
Question 456:

Which of the following is incorrect about randomized quicksort?

A. it has the same time complexity as standard quick sort
B. it has the same space complexity as standard quick sort
C. it is an in-place sorting algorithm
D. it cannot have a time complexity of O(n 2 ) in any case.
Answer: _________
Question 457:

Which of the following is an alternate name of library sort?

A. gapped insertion sort
B. binary insertion sort
C. recursive insertion sort
D. binary gap sort
Answer: _________
Question 458:

Which of the following traversal in a binary search tree results in a sorted output?

A. in order traversal
B. pre order traversal
C. post order traversal
D. breadth first traversal
Answer: _________
Question 459:

What is the best case time complexity of Tim sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 460:

What is the advantage of counting sort over quick sort?

A. counting sort has lesser time complexity when range is comparable to number of input elements
B. counting sort has lesser space complexity
C. counting sort is not a comparison based sorting technique
D. it has no advantage
Answer: _________
Question 461:

What is the worst case time complexity of bead sort (S= sum of input elements)?

A. O(n)
B. O(S)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 462:

What is the best case time complexity of bead sort (S = sum of input elements)?

A. O(n)
B. O(S)
C. O(n 2 )
D. O(n log n)
Answer: _________
Question 463:

LSD radix sort requires . . . . . . . . passes to sort N elements.

A. (w/logR)
B. N(w/logR)
C. (w/log(RN))
D. (wN/log(N))
Answer: _________
Question 464:

What is a randomized quick sort?

A. quick sort with random partitions
B. quick sort with random choice of pivot
C. quick sort with random output
D. quick sort with random input
Answer: _________
Question 465:

What is an external sorting algorithm?

A. Algorithm that uses tape or disk during the sort
B. Algorithm that uses main memory during the sort
C. Algorithm that involves swapping
D. Algorithm that are considered 'in place'
Answer: _________
Question 466:

What is the advantage of comb sort over merge sort?

A. Comb sort is an in place sorting algorithm
B. Comb sort is a stable sorting algorithm
C. Comb sort is more efficient
D. It has no advantage
Answer: _________
Question 467:

Heap sort is an extremely stable algorithm.

A. true
B. false
Answer: _________
Question 468:

Statement 1: Shell sort is a stable sorting algorithm. Statement 2: Shell sort is an in-place sorting algorithm.

A. Both statements are true
B. Statement 2 is true but statement 1 is false
C. Statement 2 is false but statement 1 is true
D. Both statements are false
Answer: _________
Question 469:

Choose the correct statement regarding binary insertion sort?

A. It has a better time complexity as compared to the standard version
B. It has a better space complexity as compared to the standard version
C. it takes less number of comparisons in the best case as compared to the standard version
D. it takes less number of comparisons in the worst case as compared to the standard version
Answer: _________
Question 470:

Bucket sort is most efficient in the case when . . . . . . . .

A. the input is non uniformly distributed
B. the input is uniformly distributed
C. the input is randomly distributed
D. the input range is large
Answer: _________
Question 471:

What is the worst case time complexity of recursive bubble sort?

A. O(n)
B. O(n log n)
C. O(n 2 )
D. O(log n)
Answer: _________
Question 472:

For the following question, how will the array elements look like after second pass? 34, 8, 64, 51, 32, 21

A. 8, 21, 32, 34, 51, 64
B. 8, 32, 34, 51, 64, 21
C. 8, 34, 51, 64, 32, 21
D. 8, 34, 64, 51, 32, 21
Answer: _________
Question 473:

Which of the following should be used to sort a huge database on a fixed-length key field?

A. Insertion sort
B. Merge sort
C. LSD radix sort
D. Quick sort
Answer: _________
Question 474:

Which of the following is not a variant of merge sort?

A. in-place merge sort
B. bottom up merge sort
C. top down merge sort
D. linear merge sort
Answer: _________
Question 475:

Consider an array of length 5, arr[5] = {9, 7, 4, 2, 1}. What are the steps of insertions done while running insertion sort on the array?

A. 7 9 4 2 1 xa0xa0 4 7 9 2 1 xa0xa0 2 4 7 9 1 xa0xa0 1 2 4 7 9
B. 9 7 4 1 2 xa0xa0 9 7 1 2 4 xa0xa0 9 1 2 4 7 xa0xa0 1 2 4 7 9
C. 7 4 2 1 9 xa0xa0 4 2 1 9 7 xa0xa0 2 1 9 7 4 xa0xa0 1 9 7 4 2
D. 7 9 4 2 1 xa0xa0 2 4 7 9 1 xa0xa0 4 7 9 2 1 xa0xa0 1 2 4 7 9
Answer: _________
Question 476:

When we realize a specific implementation of a pancake algorithm, every move when we find the greatest of the sized array and flipping can be modeled through . . . . . . . .

A. Combinations
B. Exponential functions
C. Logarithmic functions
D. Permutations
Answer: _________
Question 477:

How many passes does an insertion sort algorithm consist of?

A. N
B. N-1
C. N+1
D. N 2
Answer: _________
Question 478:

A machine needs a minimum of 200 sec to sort 1000 elements by Quick sort. The minimum time needed to sort 200 elements will be approximately . . . . . . . .

A. 60.2 sec
B. 45.54 sec
C. 31.11 sec
D. 20 sec
Answer: _________
Question 479:

The descending heap property is . . . . . . . .

A. A[Parent(i)] = A[i]
B. A[Parent(i)] <= A[i]
C. A[Parent(i)] >= A[i]
D. A[Parent(i)] > 2 * A[i]
Answer: _________
Question 480:

What is the usual size of a run in tim sort?

A. 32
B. less than 32
C. 32-64 depending on size of the array
D. 64
Answer: _________
Question 481:

What is the full form of MSD in MSD radix sort?

A. most significant digit
B. many significant digit
C. more significant digit
D. must significant digit
Answer: _________
Question 482:

Sleep sort should be preferred over permutation sort as it has better time complexity.

A. true
B. false
Answer: _________
Question 483:

Introsort algorithm is combination of . . . . . . . .

A. Quick sort and Heap sort
B. Quick sort and Shell sort
C. Heap sort and Merge sort
D. Heap sort and insertion sort
Answer: _________
Question 484:

The following function represents which sorting? void Sorting(int a[], int n)
{
bool swap = true

int first = 0

int last = n - 1

while (swap)
{

swap = false

for (int i = first

i < last

i++)
{
if (a[i] > a[i + 1])
{
swap(a[i], a[i + 1])

swap = true

}
}

if (!swap)
break

swap = false

--last

for (int i = last - 1

i >= first

i--)
{
if (a[i] > a[i + 1])
{
swap(a[i], a[i + 1])

swap = true

}
}

++first

}
}

A. Bubble sort
B. Selection sort
C. Bidirectional bubble sort
D. Odd-even sort
Answer: _________
Question 485:

The insert() procedure, given below, builds the BST on the input elements, which is the first step of the binary tree sort. Choose the correct to fill the condition. void insert(Tree* node, int newElement)
{
if(node== NULL)
{
node = createNewNode()

node-> value = newElement

node -> left = NULL

node -> right = NULL

return

}
else if(__________________)
{
insert(node->left, newElement)

}
else
{
insert(node->right, newElement)

}
}

A. newElement > node->value
B. newElement < node->value
C. newElement == root->value
D. newElement != root->value
Answer: _________
Question 486:

Consider the following code snippet, which implements the Shell sort algorithm. shellSort( int elements[], int num_elements , int incrmnts[], int num_incrmnts)
{
int incr, j, k, span, y

for(incr = 0

incr

< num_incrmnts

incr++)
{
span = incrmnts[incr]

data-structure-questions-answers-shell-sort
for( j = span

j < num_elements

j++)
{
k = j

y = elements[j]

while (________ )
{
elements [ k] = elements[k - span]

k = k - span

}
elements[k] = y

}
} Which condition will correctly implement the while loop?

A. k >= j && y < elements[k- span]
B. k >= j && y < elements[k- span]
C. k >= j || y < elements[k + span]
D. k >= span && y < elements[k- span]
Answer: _________
Question 487:

What will be the base case in the function of binary search used in the code of binary insertion sort? (high and low are the rightmost and leftmost index of array respectively and item is the element whose correct position is to be determined by the binary search function)

A. If(high<=low) { If(Item>a[low]) return low+1 return low }
B. If(high>=low) { If(Item<a[low]) return low+1 return low }
C. If(high<=low) { If(Item<a[low]) return low return low+1 }
D. If(high<=low) { If(Item>a[low]) return low return low+1 }
Answer: _________
Question 488:

Which of the following code fragment puts sorted values in an array using beads correctly?

A. for (int i = 0 i < n i++) { int j for (j = 0 j < max j++) //max is the maximum value element of given array a[] a[i] = j i}
B. for (int i = 0 i < n i++) { int j for (j = 0 j < max && beads[i * max + j] j++) //max is the maximum value element of given array a[] a[i] = j }
C. for (int i = 0 i < n i++) { int j for (j = 0 j < beads[i * max + j] j++) //max is the maximum value element of given array a[] a[j] = i }
D. for (int i = 0 i < n i++) { int j for (j = 0 j < max && beads[i * max + j] j++) //max is the maximum value element of given array a[] a[j] = i }
Answer: _________
Question 489:

Consider the code given below, which runs insertion sort: void insertionSort(int arr[], int array_size)
{
int i, j, value
for (i = 1
i < array_size
i++)
{
value = arr[i]
j = i
while (________ )
{
arr[j] = arr[j − 1]
j = j − 1
}
arr[j] = value
}
} Which condition will correctly implement the while loop?

A. (j > 0) || (arr[j - 1] > value)
B. (j > 0) && (arr[j - 1] > value)
C. (j > 0) && (arr[j + 1] < value)
D. (j > 0) && (arr[j + 1] < value)
Answer: _________
Question 490:

What will be the output of the given Java code? import java.util.Arrays
public class SortExample
{
public static void main(String[] args)
{
int[] arr = {10,7,9,5,8,4}
Arrays.sort(arr, 1, 3)
System.out.printf(Arrays.toString(arr))
}
}

A. [4,5,7,8,9,10]
B. [10,9,8,7,5,4]
C. [10,5,7,8,9,4]
D. [10,7,9,5,8,4]
Answer: _________
Question 491:

What will be the output of the given C++ code? #include <bits/stdc++.h>
using namespace std
int main()
{
int arr[] = {1, 3,4,2,5}
int n = sizeof(arr)/sizeof(arr[0])
sort(arr, arr+n)
int a
for ( a = 0
a< n
a++)
cout << arr[a] << " "
return 0
}

A. 1 2 3 4 5
B. 1 3 4 2 5
C. 5 4 3 2 1
D. error
Answer: _________
Question 492:

What is the average time complexity of in place merge sort when we use the following function for merging? void in_place_merge(int arr[], int l, int middle, int r)
{
int start2 = middle + 1
if (arr[middle] <= arr[start2])
{
return
}
while (l <= middle && start2 <= r)
{
if (arr[l] <= arr[start2])
{
l++
}
else
{
int val = arr[start2]
int index = start2
while (index != l)
{
arr[index] = arr[index - 1]
index--
}
arr[l] = val
l++
middle++
start2++
}
}
}

A. O(n log n)
B. O(n 2 )
C. O(n 2 log n)
D. O(n log n 2 )
Answer: _________
Question 493:

What will be the base case for the code of recursive insertion sort ?

A. if(n < 1) return
B. if(n == 0) return
C. if(n <= 1) return
D. If(n == 2) return
Answer: _________
Question 494:

What will be the output of the given C++ code? #include <bits/stdc++.h>
using namespace std
int main()
{
int arr[] = {1, 3,4,2,5}
int n = sizeof(arr)/sizeof(arr[0])
sort(arr+2, arr+n, greater<int>())
int a
for (int a = 0
a < n
a++)
cout << arr[a] << " "
return 0
}

A. 1 2 3 4 5
B. 1 5 4 3 2
C. 5 4 3 2 1
D. 1 3 5 4 2
Answer: _________
Question 495:

There is a one line error in the following routine. Find that line. 1. int Max(int a[], int n)
2. {
3. int mi, i
4. for (mi = 0, i = 0
i < n
i++)
5. if (a[i] > a[mi])
6. mi = i
7. return mi
8. }

A. Line 2
B. Line 4
C. Line 6
D. Line 5
Answer: _________
Question 496:

There is one small error in the following flip routine. Find out which line it is on. 1 void flip(int arr[], int i)
2 {
3 int t, init = 0
4 while (init < i)
5 {
6 t = arr[init]
7 arr[i] = arr[init]
8 arr[i] = t
9 init++
10 i--
11 }
12 }

A. Line 3
B. Line 5
C. Line 7
D. Line 9
Answer: _________
Question 497:

What will be the output of the given C++ code? #include <bits/stdc++.h>
using namespace std
int main()
{
int arr[] = {1,3,4,2,5}
int n = sizeof(arr)/sizeof(arr[0])
sort(arr, arr+n, greater<int>())
int a
for (a = 0
a < n
a++)
cout << arr[a] << " "
return 0
}

A. 1 2 3 4 5
B. 1 3 4 2 5
C. 5 4 3 2 1
D. error
Answer: _________
Question 498:

Which of the following statements is the basic for loop for a shell sort algorithm?

A. for(increment=N/2 increment>0 increment/=2)
B. for(i=1 i<n i++)
C. for(i=n/2 i>=0 i- -)
D. for(i=0 i< n i++ numelements- -)
Answer: _________
Question 499:

Choose the correct option to fill? X so that the code given below implements the Heap sort. #include <stdio.h>
void heapify(int arr[], int n, int i)
{
int largest = i
// Initialize largest as root
int l = 2*i + 1
// left = 2*i + 1
int r = 2*i + 2
// right = 2*i + 2
if (l < n && arr[l] > arr[largest])
largest = l
if (r < n && arr[r] > arr[largest])
largest = r
if (largest != i)
{
swap(arr[i], arr[largest])
heapify(arr, n, largest)
}
}
void heapSort(int arr[], int n)
{
for (int i = n / 2 - 1
i >= 0
i--)
heapify(arr, n, i)
for (int i=n-1
i>=0
i--)
{
X
heapify(arr, i, 0)
}
}
void printArray(int arr[], int n)
{
for (int i=0
i<n
++i)
printf(“%d”,arr[i])
printf(“
”)
}
int main()
{
int arr[] = {12, 11, 13, 5, 6, 7}
int n = sizeof(arr)/sizeof(arr[0])
heapSort(arr, n)
printf(“Sorted array is
")
printArray(arr, n)
}

A. swap(arr[0], arr[n])
B. swap(arr[i], arr[n])
C. swap(arr[0], arr[i])
D. swap(arr[i], arr[2*i])
Answer: _________
Question 500:

Which of the following function chooses a random index as pivot.

A. void partition_random(int arr[], int low, int high) { srand(time(NULL)) int random = low + rand() % (high - low) swap(arr[random], arr[high]) }
B. void partition_random(int arr[], int low, int high) { srand(time(NULL)) int random = high + rand() % (high - low) swap(arr[random], arr[high]) }
C. void partition_random(int arr[], int low, int high) { srand(1) int random = low + rand() % (high - low) swap(arr[random], arr[high]) }
D. void partition_random(int arr[], int low, int high) { srand(time(NULL)) int random = low + rand() % (high - low-1) swap(arr[low], arr[high]) }
Answer: _________
Question 501:

What will be the base case for the code of recursive bubble sort?

A. if(n < 1) return
B. if(n == 0) return
C. if(n == 1) return
D. If(n == 2) return
Answer: _________
Question 502:

What will be the output of the given Java code? import java.util.Arrays
public class SortExample
{
public static void main(String[] args)
{
// Our arr contains 8 elements
int[] arr = {10,7,9,5,8,4}
Arrays.sort(arr)
System.out.printf(Arrays.toString(arr))
}
}

A. [4,5,7,8,9,10]
B. [10,9,8,7,5,4]
C. 4,5,7,8,9,10
D. error
Answer: _________

Answer Key

1: C
2: D
3: A
4: D
5: C
6: B
7: C
8: D
9: C
10: D
11: A
12: D
13: C
14: B
15: C
16: D
17: A
18: D
19: C
20: B
21: C
22: D
23: D
24: A
25: B
26: C
27: A
28: A
29: A
30: B
31: A
32: B
33: A
34: C
35: C
36: C
37: D, F
38: B
39: D
40: D
41: C
42: B
43: B
44: A
45: C
46: B
47: C
48: B
49: A
50: B
51: A
52: B
53: A
54: B
55: C
56: A
57: D
58: B
59: B
60: D
61: A
62: C
63: B, F
64: D
65: C
66: B
67: B
68: C
69: C
70: A
71: B
72: B
73: A
74: C
75: A
76: C
77: B
78: A
79: B
80: A
81: B
82: C
83: B
84: D
85: A
86: C
87: A
88: A
89: C
90: B
91: B
92: A
93: C
94: D
95: A
96: A
97: D
98: C
99: B
100: C
101: D
102: A
103: B
Solution: Heap Sort is a sorting algorithm with a worst-case time complexity of O(n log n) . It is not stable because the relative order of equal elements may not be preserved during the sorting process. Option A: Counting Sort is not correct because it has a time complexity of O(n + k) , where k is the range of the input, and it is stable. Option C: Merge Sort has a worst-case time complexity of O(n log n) , but it is a stable sorting algorithm. Option D: Quick Sort has an average-case time complexity of O(n log n) , but its worst-case time complexity is O(n²) . It is also not stable. Therefore, the correct answer is Option B: Heap Sort , as it meets the criteria of O(n log n) in the worst case and is not stable.
104: C
105: B
106: D
107: B
108: A
109: B, E
110: C
111: D
112: A
113: D
114: B
115: D
116: B, F, K, M
117: A
118: B
119: C
120: B
121: A
122: C
123: C
124: A, E
125: C
126: B
127: B
128: D
129: C
130: B
131: C
132: D
133: A
134: A
135: A
136: B
137: A
138: D
139: B
140: B
141: D
142: A
143: A
144: A
145: B
146: C
147: C
148: A
149: A
150: D
151: A
152: A
153: C
154: B
155: A
156: B
157: D
158: A
159: C
160: A
161: B
162: B
163: A
164: D
165: B
166: C
167: C
168: A
169: A
170: A
171: B
172: D
173: A
174: C
175: A
176: C
177: D
178: D
179: D
180: D
181: D
182: B
183: A
184: C
185: A
186: B
187: B
188: A
189: A
190: D
191: A
192: A
193: A
194: C
195: C
196: C
197: C
198: C
199: D
200: B
201: A
202: B
203: B
204: A
205: B
206: C
207: C
208: B
209: A
210: A
211: D
212: D
213: B
214: D
215: A
216: C
217: A
218: D
219: C
220: B
221: C
222: B
223: D
224: C
225: B
226: C
227: B
228: D
229: B
230: A
231: B
232: D
233: A
234: C
235: B
236: D
237: D
238: B
239: C
240: C
241: D
242: B
243: A
244: C
245: A
246: C
247: A
248: D
249: C
250: A
251: A
252: D
253: D
254: A
255: D
256: A
257: A
258: B
259: B
260: B
261: C
262: C
263: D
264: A
265: A
266: D
267: B
268: D
269: C
270: C
271: B
272: C
273: B
274: B
275: C
276: A
277: A
278: C
279: B
280: A
281: D
282: D
283: A
284: B
285: C
286: A
287: A
288: B
289: A
290: C
291: A
292: A
293: D
294: A
295: A
296: B
297: D
298: D
299: B
300: B
301: B
302: A
303: D
304: B
305: A
306: D
307: C
308: A
309: C
310: A
311: B
312: A
313: B
314: A
315: B
316: A
317: B
318: B
319: B
320: B
321: A
322: A
323: C
324: B
325: A
326: B
327: A
328: A
329: A
330: C
331: A
332: D
333: C
334: B
335: A
336: C
337: A
338: D
339: B
340: A
341: C
342: B
343: A
344: C
345: A
346: B
347: B
348: A
349: D
350: B
351: A
352: A
353: B
354: C
355: D
356: B
357: A
358: D
359: B
360: A
361: D
362: C
363: C
364: C
365: D
366: B
367: D
368: A
369: B
370: A
371: B
372: C
373: A
374: A
375: B
376: A
377: A
378: B
379: B
380: A
381: C
382: C
383: A
384: A
385: D
386: B
387: B
388: D
389: B
390: A
391: A
392: B
393: C
394: A
395: C
396: A
397: A
398: D
399: A
400: D
401: D
402: D
403: A
404: C
405: C
406: C
407: B
408: C
409: D
410: A
411: D
412: C
413: B
414: C
415: D
416: B
417: B
418: B
419: A
420: B
421: C
422: B
423: C
424: D
425: A
426: C
427: C
428: B
429: B
430: C
431: A
432: C
433: B
434: B
435: D
436: C
437: A
438: C
439: B
440: A
441: D
442: C
443: D
444: B
445: D
446: C
447: C
448: B
449: B
450: B
451: D
452: A
453: A
454: A
455: B
456: D
457: A
458: A
459: A
460: A
461: B
462: A
463: A
464: B
465: A
466: A
467: A
468: B
469: D
470: B
471: C
472: D
473: C
474: D
475: A
476: D
477: B
478: C
479: C
480: C
481: A
482: B
483: A
484: C
485: B
486: D
487: C
488: B
489: B
490: D
491: A
492: B
493: C
494: D
495: B
496: C
497: C
498: A
499: C
500: A
501: C
502: A