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.
| 351. |
What is the best case complexity of selection sort?(a) O(nlogn)(b) O(logn)(c) O(n)(d) O(n^2)This question was addressed to me in an interview for job.Query is from Selection Sort topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (d) O(n^2) |
|
| 352. |
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 1The question was posed to me in a job interview.Query is from Selection Sort in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct option is (d) 4 and 1 |
|
| 353. |
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 5This question was posed to me at a job interview.Origin of the question is Selection Sort in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right option is (a) 5 and 4 |
|
| 354. |
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 elementsThe question was posed to me in an interview for internship.The query is from Selection Sort topic in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (b) It is not scalable |
|
| 355. |
What is the average case complexity of selection sort?(a) O(nlogn)(b) O(logn)(c) O(n)(d) O(n^2)This question was addressed to me during an online interview.Origin of the question is Selection Sort topic in section Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (d) O(n^2) The EXPLANATION is: In the average CASE, even if the input is partially sorted, selection sort behaves as if the ENTIRE array is not sorted. Selection sort is insensitive to input. |
|
| 356. |
Which of the following is not an exchange sort?(a) Bubble Sort(b) Quick Sort(c) Partition-exchange Sort(d) Insertion SortThe question was asked in quiz.Question is from Insertion sort topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (d) Insertion Sort |
|
| 357. |
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) 14This question was addressed to me in an online quiz.This key question is from Insertion sort in portion Sorting of Data Structures & Algorithms II |
|
Answer» Right OPTION is (b) 4 |
|
| 358. |
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 falseI got this question during an online interview.I need to ask this question from Insertion sort in section Sorting of Data Structures & Algorithms II |
|
Answer» Right option is (b) Statement 1 is TRUE but statement 2 is false |
|
| 359. |
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 14 7 9 2 12 4 7 9 11 2 4 7 9(b) 9 7 4 1 29 7 1 2 49 1 2 4 71 2 4 7 9(c) 7 4 2 1 94 2 1 9 72 1 9 7 41 9 7 4 2(d) 7 9 4 2 12 4 7 9 14 7 9 2 11 2 4 7 9I have been asked this question at a job interview.I would like to ask this question from Insertion sort in section Sorting of Data Structures & Algorithms II |
|
Answer» Right option is (a) 7 9 4 2 1 |
|
| 360. |
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 SortI had been asked this question in class test.The origin of the question is Insertion sort in portion Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (d) INSERTION SORT The best explanation: The insertion sort is good for sorting small ARRAYS. It sorts smaller arrays faster than any other sorting ALGORITHM. |
|
| 361. |
Insertion sort is an example of an incremental algorithm.(a) True(b) FalseThe question was asked during an interview.My question is based upon Insertion sort in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (a) True |
|
| 362. |
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)The question was asked by my school principal while I was bunking the class.Question is taken from Insertion sort topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (b) O(n^2) For explanation: The use of binary search reduces the TIME of finding the correct position from O(n) to O(LOGN). But the worst case of insertion sort REMAINS O(n^2) because of the series of swapping operations required for each insertion. |
|
| 363. |
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 SortI got this question during an online interview.I'd like to ask this question from Insertion sort in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right option is (c) INSERTION Sort |
|
| 364. |
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-placeI had been asked this question in an interview for internship.My question is taken from Insertion sort in division Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (a) insertion sort is stable and it sorts In-place |
|
| 365. |
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 arrayThe question was posed to me in my homework.I'd like to ask this question from Insertion sort in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct option is (B) ARRAY SORTED in reverse order |
|
| 366. |
For the best case input, the running time of an insertion sort algorithm is?(a) Linear(b) Binary(c) Quadratic(d) Depends on the inputThis question was posed to me by my college director while I was bunking the class.I'd like to ask this question from Insertion sort in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct CHOICE is (a) Linear |
|
| 367. |
Which of the following sorting algorithms is the fastest for sorting small arrays?(a) Quick sort(b) Insertion sort(c) Shell sort(d) Heap sortThis question was addressed to me during an interview for a job.This question is from Insertion sort in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct ANSWER is (B) Insertion sort |
|
| 368. |
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, adaptiveThe question was asked in examination.The question is from Insertion sort topic in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (d) STABLE, adaptive |
|
| 369. |
Binary search can be used in an insertion sort algorithm to reduce the number of comparisons.(a) True(b) FalseThe question was asked in examination.This intriguing question comes from Insertion sort topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT ANSWER is (a) True Easy explanation - Binary search can be used in an INSERTION SORT algorithm to reduce the NUMBER of comparisons. This is called a Binary insertion sort. |
|
| 370. |
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 ifThis question was posed to me by my school teacher while I was bunking the class.The doubt is from Insertion sort in division Sorting of Data Structures & Algorithms II |
|
Answer» Right ANSWER is (c) for and while |
|
| 371. |
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 systemsThe question was asked by my college director while I was bunking the class.This interesting question is from Insertion sort topic in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct option is (a) arranging a pack of playing cards |
|
| 372. |
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)This question was addressed to me in quiz.This interesting question is from Insertion sort in portion Sorting of Data Structures & Algorithms II |
|
Answer» The correct choice is (c) O(N) |
|
| 373. |
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)/3I got this question in my homework.I want to ask this question from Insertion sort topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (a) N(N-1)/4 |
|
| 374. |
Any algorithm that sorts by exchanging adjacent elements require O(N^2) on average.(a) True(b) FalseThis question was posed to me during an interview.My doubt stems from Insertion sort topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (a) True |
|
| 375. |
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)I had been asked this question at a job interview.This intriguing question comes from Insertion sort in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct choice is (d) O(N^2) |
|
| 376. |
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 sortI had been asked this question in an online interview.Asked question is from Insertion sort topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct option is (a) Binary heap |
|
| 377. |
How many passes does an insertion sort algorithm consist of?(a) N(b) N-1(c) N+1(d) N^2This question was addressed to me during an online interview.The origin of the question is Insertion sort topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT option is (b) N-1 Best explanation: An insertion ALGORITHM consists of N-1 PASSES when an ARRAY of N elements is given. |
|