InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 151. |
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)I had been asked this question in homework.This is a very interesting question from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (a) O(n^2) |
|
| 152. |
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 usedI have been asked this question during an interview.My enquiry is from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (a) is equal to NUMBER of elements in the array |
|
| 153. |
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.4This question was addressed to me in an interview for job.I need to ask this question from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct CHOICE is (c) 1.3 |
|
| 154. |
Comb sort is an improved version of _______(a) Selection sort(b) Bubble sort(c) Insertion sort(d) Merge sortI had been asked this question in quiz.This question is from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (b) Bubble sort |
|
| 155. |
Bubble sort performs better as compared to cocktail sort.(a) True(b) FalseThe question was posed to me by my school teacher while I was bunking the class.I would like to ask this question from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct CHOICE is (b) False |
|
| 156. |
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,3The question was posed to me at a job interview.Asked question is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (a) 4,2 |
|
| 157. |
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)I had been asked this question in final exam.The doubt is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT CHOICE is (c) O(n^2) For explanation: Cocktail sort takes O(n^2) time on AVERAGE as it KEEPS on applying bubble sort on the elements in TWO phases until they are sorted. This is the same as the average time complexity of bubble sort. |
|
| 158. |
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)I got this question during an interview for a job.My doubt stems from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (a) O(N) |
|
| 159. |
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)I have been asked this question during a job interview.I would like to ask this question from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right CHOICE is (c) O(n^2) |
|
| 160. |
Cocktail sort uses which of the following methods for sorting the input?(a) selection(b) partitioning(c) merging(d) exchangingI got this question at a job interview.My question is taken from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (d) exchanging To explain: Cocktail sort USES a method of exchanging as it swaps the elements which are out of order. This SWAPPING is done in two phases i.e. FORWARD phase and BACKWARD phase. |
|
| 161. |
Cocktail sort is a comparison based sort.(a) True(b) FalseThe question was asked in an interview for job.My question comes from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (a) True |
|
| 162. |
Which of the following sorting algorithm is in place?(a) cocktail sort(b) merge sort(c) counting sort(d) radix sortThe question was asked in exam.My enquiry is from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct option is (a) cocktail sort |
|
| 163. |
Which of the following sorting algorithm is NOT stable?(a) Quick sort(b) Cocktail sort(c) Bubble sort(d) Merge sortThe question was asked at a job interview.The doubt is from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT CHOICE is (a) Quick sort Easy explanation - Out of the given options quick sort is the only algorithm which is not stable. Cocktail sort LIKE BUBBLE sort is a stable sorting algorithm. |
|
| 164. |
Auxiliary space requirement of cocktail sort is _____________(a) O(n)(b) O(log n)(c) O(1)(d) O(n^2)I have been asked this question in an internship interview.This intriguing question originated from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right CHOICE is (c) O(1) |
|
| 165. |
Cocktail sort is a variation of _____________(a) Bubble sort(b) Selection sort(c) Insertion sort(d) Gnome sortI got this question in my homework.Asked question is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right ANSWER is (a) Bubble sort |
|
| 166. |
Cocktail sort is also known as ________________(a) bidirectional sort(b) bubble sort(c) brick sort(d) ripple sortI got this question by my school principal while I was bunking the class.My doubt is from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct choice is (d) ripple sort |
|
| 167. |
Which of the following is an adaptive sorting algorithm?(a) heap sort(b) strand sort(c) selection sort(d) merge sortThe question was posed to me at a job interview.The above asked question is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (b) STRAND sort |
|
| 168. |
Strand sort algorithm used which of the following method for sorting a list?(a) merging(b) selection(c) insertion(d) partitioningI have been asked this question in class test.This interesting question is from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT ANSWER is (b) SELECTION |
|
| 169. |
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)The question was asked in an interview for job.My question is taken from Sorting topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT option is (C) O(n^2) EASY explanation - WORST CASE time complexity of strand sort is O(n^2). It occurs in the case where the input array is in reverse sorted order. |
|
| 170. |
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)I got this question in an internship interview.This intriguing question originated from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (a) O(n) |
|
| 171. |
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)I got this question in an internship interview.This key question is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct CHOICE is (c) O(n^2) |
|
| 172. |
Strand sort is a stable sorting algorithm.(a) true(b) falseThe question was asked at a job interview.I want to ask this question from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (a) true |
|
| 173. |
Strand sort is a comparison based sorting algorithm.(a) true(b) falseI have been asked this question in exam.Enquiry is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right OPTION is (a) true |
|
| 174. |
Which of the following sorting algorithm is not in place?(a) quick sort(b) strand sort(c) cycle sort(d) heap sortI had been asked this question in homework.The origin of the question is Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Right OPTION is (B) STRAND sort |
|
| 175. |
What is the auxiliary space complexity of strand sort?(a) O(n)(b) O(1)(c) O(log n)(d) O(n log n)I got this question during an internship interview.I want to ask this question from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (a) O(n) |
|
| 176. |
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 elementsThe question was posed to me during an internship interview.The doubt is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT option is (a) when input array is ALREADY sorted For EXPLANATION: The best CASE of strand sort occurs when the input array is already sorted. In this case, it has linear TIME complexity. |
|
| 177. |
Strand sort is most efficient for data stored in?(a) linked list(b) arrays(c) trees(d) graphsThe question was posed to me in class test.Enquiry is from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (a) linked list Explanation: Strand sort is most EFFICIENT when data is STORED in a linked list as it involves many insertions and deletions which is performed quite efficiently with the help of a linked list. Using an array would INCREASE time COMPLEXITY significantly. |
|
| 178. |
Which one of the following sorting algorithm requires recursion?(a) pigeonhole sort(b) strand sort(c) insertion sort(d) counting sortThe question was asked in unit test.Question is taken from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (b) strand SORT |
|
| 179. |
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 algorithmI have been asked this question by my college professor while I was bunking the class.Query is from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» Right choice is (d) it is an in PLACE sorting algorithm |
|
| 180. |
Which of the following sorting algorithm is not in place?(a) library sort(b) quick sort sort(c) heap sort(d) gnome sortThe question was asked in an interview.The origin of the question is Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct option is (a) LIBRARY SORT |
|
| 181. |
Which of the following is an adaptive sorting algorithm?(a) library sort(b) merge sort(c) heap sort(d) selection sortI have been asked this question in a job interview.I'm obligated to ask this question of Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right OPTION is (a) library sort |
|
| 182. |
What is the auxiliary space complexity of library sort?(a) O(n)(b) O(1)(c) O(n log n)(d) O(n^2)I got this question in an online quiz.Enquiry is from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT option is (a) O(N) Easy explanation - The auxiliary space required by library SORT is O(n). This space is taken up by the GAPS PRESENT in between successive elements. |
|
| 183. |
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 complexityThis question was posed to me in an online interview.This key question is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct choice is (a) Library sort has a BETTER average time complexity |
|
| 184. |
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 sortI got this question in an interview for job.This interesting question is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» The correct ANSWER is (a) gapped insertion sort |
|
| 185. |
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)This question was addressed to me in an international level competition.This intriguing question comes from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (c) O(n^2) |
|
| 186. |
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)The question was posed to me during an interview.This interesting question is from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (a) O(n) For explanation: The best case time COMPLEXITY of library SORT is O(n). It occurs in the case when the input is already/almost sorted. |
|
| 187. |
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)I had been asked this question in homework.I would like to ask this question from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (b) O(n log n) |
|
| 188. |
Library sort is a comparison based sort.(a) true(b) falseThis question was addressed to me in my homework.My question is based upon Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (a) true Easy EXPLANATION - In library sort, we need to compare elements in order to insert them at the correct index. So we can say that it uses comparisons in order to sort the ARRAY. THUS it qualifies as a COMPARISON based sort. |
|
| 189. |
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 sortI got this question during a job interview.Asked question is from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» Correct choice is (b) library sort |
|
| 190. |
Which of the following sorting algorithm is stable?(a) Selection sort(b) Quick sort(c) Library sort(d) Heap sortThis question was posed to me in an internship interview.The query is from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (C) Library sort |
|
| 191. |
Library sort is a modified version of which of the following sorting algorithm?(a) Bubble sort(b) selection sort(c) insertion sort(d) quick sortI got this question in final exam.I'm obligated to ask this question of Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (c) INSERTION sort To EXPLAIN: LIBRARY sort requires the use of Insertion sort and BINARY search in its code. So it is a modified version of insertion sort. |
|
| 192. |
Library sort is an online sorting algorithm.(a) true(b) falseThis question was posed to me during a job interview.This is a very interesting question from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» Correct choice is (a) true |
|
| 193. |
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 disadvantageThis question was addressed to me in exam.This intriguing question originated from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (b) library sort has greater SPACE complexity |
|
| 194. |
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 sortI got this question during an internship interview.Origin of the question is Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT choice is (b) cycle SORT Easy EXPLANATION - Cycle sort is a slow sorting algorithm but it requires a minimum number of write operations in ORDER to sort a given ARRAY. So it is useful when the write/swap operation is expensive. |
|
| 195. |
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) 3This question was addressed to me during an online interview.Asked question is from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct choice is (a) 4 |
|
| 196. |
Which of the following sorting algorithm uses the method of insertion?(a) cycle sort(b) bubble sort(c) quick sort(d) selection sortI have been asked this question in unit test.My question is taken from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (a) cycle sort |
|
| 197. |
Cycle sort is a comparison based sort.(a) true(b) falseThis question was posed to me in an interview for job.The origin of the question is Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct option is (a) true |
|
| 198. |
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 algorithmThis question was addressed to me by my school teacher while I was bunking the class.My doubt stems from Sorting topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» Right choice is (c) it REQUIRES minimal write operations |
|
| 199. |
Which of the following sorting algorithm is in-place?(a) Merge sort(b) Cycle sort(c) Counting sort(d) Radix sortThis question was addressed to me during a job interview.My question is based upon Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT OPTION is (b) Cycle sort Best EXPLANATION: Cycle sort has an auxiliary SPACE COMPLEXITY of O(1). So it qualifies to be an in-place sort. All other given options are not in place sorting algorithm. |
|
| 200. |
Cycle sort is an adaptive sorting algorithm.(a) true(b) falseThe question was asked in examination.Query is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT OPTION is (b) false Easy EXPLANATION - The time complexity of CYCLE sort is O(n^2) in any case. So cycle sort algorithm is not adaptive, as it will take the same time to sort an already sorted array and any other randomly ARRANGED array. |
|