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.
| 1. |
What is the basic principle in Rabin Karp algorithm?(a) Hashing(b) Sorting(c) Augmenting(d) Dynamic ProgrammingPlease answer the question asap those who know Rabin Karp algorithm. |
|
Answer» Right option is (a) Hashing |
|
| 2. |
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» Correct answer is (b) O(n LOG n) |
|
| 3. |
Which of the following is a variant of insertion sort?(a) selection sort(b) shell sort(c) odd-even sort(d) stupid sortPlease answer. |
|
Answer» The correct OPTION is (b) shell sort |
|
| 4. |
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 sortPlease answer this question of dsa. |
|
Answer» The correct ANSWER is (c) bucket sort |
|
| 5. |
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 sortRadix sort people please answer. |
|
Answer» Correct OPTION is (B) Radix sort has better cache performance than quick sort |
|
| 6. |
Which of the following sorting algorithm is not a constituent of introsort?(a) selection sort(b) quicksort(c) insertion sort(d) heap sortintrosort knowledgeable people please answer. |
|
Answer» RIGHT answer is (a) selection sort Explanation: Introsort is a HYBRID sorting algorithm which means it USES more than one sorting algorithm as a routine. It may use quick sort or heap sort or INSERTION sort depending on the given situation. |
|
| 7. |
Shell sort is also known as _____________(a) diminishing decrement sort(b) diminishing increment sort(c) partition exchange sort(d) diminishing insertion sortA very nice question close to me from dsa. |
|
Answer» Right OPTION is (b) DIMINISHING increment sort |
|
| 8. |
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 algorithmI got this question in an online quiz.Question is taken from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) it has a low SPACE complexity |
|
| 9. |
The worst case time complexity of tree sort remains unaffected when implemented with an unbalanced tree or a balanced tree.(a) True(b) FalseThe question was posed to me during an interview.This interesting question is from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct CHOICE is (b) False |
|
| 10. |
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 BSTThis question was addressed to me in exam.My question is based upon Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (d) using ordinary BST |
|
| 11. |
Which of the following sorting algorithm is not in place?(a) insertion sort(b) quick sort(c) tree sort(d) gnome sortI got this question in an online quiz.I want to ask this question from Sorting topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» The correct choice is (c) TREE sort |
|
| 12. |
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 sortI got this question in an interview.Origin of the question is Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT answer is (B) its every implementation is adaptive For explanation: Every implementation of tree sort is not adaptive. It BECOMES adaptive only when IMPLEMENTED with a splay tree as BST. |
|
| 13. |
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 BSTI have been asked this question in examination.The origin of the question is Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (c) when implemented with a splay tree as BST |
|
| 14. |
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)I got this question in an internship interview.The query is from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (C) O(n^2) |
|
| 15. |
What is the auxiliary space complexity of tree sort?(a) O(1)(b) O(n)(c) O(log n)(d) O(n log n)This question was posed to me in an internship interview.My query is from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (b) O(N) |
|
| 16. |
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)I had been asked this question in an online quiz.My doubt is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT ANSWER is (B) O(n log n) For EXPLANATION: The BEST case time complexity of tree sort is the same as its average case complexity. So best case time complexity is O(n log n). |
|
| 17. |
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)This question was posed to me by my school principal while I was bunking the class.I'd like to ask this question from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Right ANSWER is (b) O(N log n) |
|
| 18. |
Which of the following is a comparison based sort?(a) tree sort(b) radix sort(c) counting sort(d) pigeonhole sortI got this question during an interview.This key question is from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (a) tree SORT |
|
| 19. |
Which of the following sorting algorithm uses a binary search tree?(a) radix sort(b) tree sort(c) odd-even sort(d) bead sortThis question was posed to me in exam.The above asked question is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (b) tree SORT |
|
| 20. |
Which of the following sorting algorithm is stable?(a) Selection sort(b) Quick sort(c) Tree sort(d) Heap sortI had been asked this question in semester exam.I'd like to ask this question from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (C) Tree sort |
|
| 21. |
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 traversalThis question was posed to me in semester exam.My doubt stems from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (a) in ORDER traversal |
|
| 22. |
Tree sort is an online sorting algorithm.(a) True(b) FalseI got this question during an online interview.This intriguing question originated from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) True |
|
| 23. |
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 treeThe question was asked in examination.Question is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct ANSWER is (c) binary search TREE |
|
| 24. |
What will be the recurrence relation of the code of recursive insertion 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) + cThe question was asked in an interview for job.The origin of the question is Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT ANSWER is (c) T(n) = T(n-1) + n Easy explanation - The recurrence relation of the CODE of recursive insertion sort is T(n) = T(n-1) + n. It can be solved by the method of substitution and is found to be EQUAL to n^2. |
|
| 25. |
Which of the following sorting algorithm is stable?(a) Selection sort(b) Quick sort(c) Insertion sort(d) Heap sortThe question was posed to me in an online quiz.The origin of the question is Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT choice is (c) Insertion sort Best explanation: Out of the GIVEN options insertion sort is the only ALGORITHM which is stable. It is because the elements with identical values appear in the same order in the OUTPUT array as they were in the INPUT array. |
|
| 26. |
Insertion sort is an online sorting algorithm.(a) true(b) falseThe question was posed to me at a job interview.I want to ask this question from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» The correct option is (a) true |
|
| 27. |
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 advantageThis question was posed to me in examination.This interesting question is from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (d) it has no significant advantage |
|
| 28. |
Which of the following sorting algorithm uses a binary search?(a) radix sort(b) binary insertion sort(c) odd-even sort(d) bead sortI had been asked this question during an internship interview.I need to ask this question from Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (b) binary insertion sort Best explanation: Binary insertion sort makes use of a binary SEARCH algorithm. It is USED to find the correct index in the array where the element should be INSERTED. |
|
| 29. |
Which of the following sorting algorithm is stable?(a) Selection sort(b) Quick sort(c) Binary insertion sort(d) Heap sortThis question was addressed to me by my college professor while I was bunking the class.The origin of the question is Sorting topic in portion Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT OPTION is (c) Binary INSERTION sort The best EXPLANATION: Out of the given options binary insertion sort is the only algorithm which is stable. It is because the elements with identical values appear in the same order in the output array as they were in the INPUT array. |
|
| 30. |
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 nThis question was addressed to me in an interview for job.My question is based upon Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (c) log N |
|
| 31. |
Binary Insertion sort is an online sorting algorithm.(a) True(b) FalseI have been asked this question during an interview.My question is based upon Sorting in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (a) True |
|
| 32. |
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 advantageI got this question in examination.This key question is from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» The correct option is (C) it makes less NUMBER of COMPARISONS |
|
| 33. |
Which of the following is a variation of bubble sort?(a) selection sort(b) odd even sort(c) cocktail sort(d) stupid sortI had been asked this question in semester exam.Query is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» RIGHT choice is (b) ODD even sort The BEST explanation: Odd even sort is a variation of bubble sort. But unlike bubble sort, odd even sort traverses the array in TWO phases- odd phase and even phase. |
|
| 34. |
Which of the following sorting algorithm is stable?(a) Selection sort(b) Quick sort(c) Bubble sort(d) Heap sortThe question was asked in an interview.My question is taken from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right choice is (c) Bubble sort |
|
| 35. |
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) + cI have been asked this question in an interview.Question is taken from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (c) T(n) = T(n-1) + n |
|
| 36. |
Bubble sort is also known as ___________(a) stupid sort(b) ship sort(c) sinking sort(d) shell sortThis question was posed to me in examination.My question is based upon Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (c) sinking sort |
|
| 37. |
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 advantageThe question was asked by my college director while I was bunking the class.This intriguing question comes from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT ANSWER is (d) it has no significant advantage |
|
| 38. |
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)I had been asked this question in final exam.This interesting question is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Right answer is (c) O(INFINITY) |
|
| 39. |
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)I had been asked this question in exam.This intriguing question originated from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct answer is (B) O(n) |
|
| 40. |
What is the auxiliary space requirement of permutation sort?(a) O(n)(b) O(1)(c) O(log n)(d) O(n log n)The question was asked in a job interview.I would like to ask this question from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT option is (b) O(1) Best explanation: PERMUTATION sort algorithm does not require any extra space for sorting the input array. THUS its auxiliary space requirement is O(1). |
|
| 41. |
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 arrayThis question was posed to me in final exam.This intriguing question comes from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT answer is (a) generating random permutations of its INPUT |
|
| 42. |
Which of the following is not an alternative name of permutation sort?(a) stupid sort(b) bogo sort(c) donkey sort(d) monkey sortThis question was addressed to me in an interview for job.I would like to ask this question from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» Correct option is (c) DONKEY SORT |
|
| 43. |
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)The question was posed to me during an internship interview.I'd like to ask this question from Sorting in division Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT answer is (d) O(n^2.7) |
|
| 44. |
Stooge sort is a stable sorting algorithm.(a) true(b) falseThis question was addressed to me in unit test.This question is from Sorting in portion Sorting of Data Structures & Algorithms II |
|
Answer» The correct choice is (b) false |
|
| 45. |
Stooge sort is a comparison based sorting algorithm.(a) true(b) falseI got this question in an interview for job.My doubt stems from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) true |
|
| 46. |
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 arrayThis question was addressed to me in a job interview.I need to ask this question from Sorting topic in section Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (d) compare FIRST and last element of the array |
|
| 47. |
What is the space complexity of stooge sort?(a) O(n)(b) O(1)(c) O(log n)(d) O(n log n)The question was posed to me in an internship interview.My question is from Sorting topic in chapter Sorting of Data Structures & Algorithms II |
|
Answer» CORRECT option is (a) O(N) The best I can EXPLAIN: The space COMPLEXITY of the stooge SORT is O(n). It is used to store the input array. |
|
| 48. |
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 caseI have been asked this question in homework.Origin of the question is Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The correct choice is (d) it has the same time complexity in any CASE |
|
| 49. |
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)The question was posed to me in an international level competition.The question is from Sorting topic in division Sorting of Data Structures & Algorithms II |
|
Answer» Correct answer is (d) T(n) = 3T(2/3n) + O(1) |
|
| 50. |
Which one of the following sorting algorithm requires recursion?(a) odd even sort(b) stooge sort(c) selection sort(d) counting sortThe question was asked in exam.The question is from Sorting in section Sorting of Data Structures & Algorithms II |
|
Answer» The CORRECT answer is (b) stooge sort |
|