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 will be the time complexity of the code to find a minimum element from an array of size n and uses square root decomposition(exclude pre processing time)?(a) O(√n)(b) O(n)(c) O(1)(d) O(n^2)The question was posed to me during an interview for a job.My question comes from Miscellaneous in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (a) O(√n) |
|
| 2. |
Mo’s algorithm can only be used for problems where the query can be calculated from the result of the previous query.(a) true(b) falseI had been asked this question in an interview.My doubt is from Miscellaneous in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» RIGHT answer is (a) true The explanation is: Mo’s ALGORITHM uses the result of the previous query in ORDER to compute the result of the given query. It cannot be implemented where such a SCENARIO is not POSSIBLE. |
|
| 3. |
What will be the worst case time complexity of code to find sum in given query range (l,r) in an array of size n with q number of such queries when we apply MO’s algorithm?(a) O(n*q)(b) O(n)(c) O((q+n)√n)(d) O(q*√n)The question was asked in an interview for internship.This question is from Miscellaneous in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct option is (C) O((q+N)√n) |
|
| 4. |
What will be the worst case time complexity of code to find sum in given query range (l,r) in an array of size n with q number of such queries?(a) O(n)(b) O(q)(c) O(n*q)(d) O(n+q)I have been asked this question in an online quiz.The above asked question is from Miscellaneous topic in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right answer is (c) O(n*q) |
|
| 5. |
Square root decomposition technique is only applicable when the number of indices in an array is a perfect square.(a) true(b) falseThe question was asked in class test.I want to ask this question from Miscellaneous in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» RIGHT choice is (b) false For EXPLANATION: Square root decomposition TECHNIQUE can be applied to an ARRAY with any number of indices. It does not REQUIRE this number to be a perfect square. |
|
| 6. |
What will be the time complexity of update query operation in an array of size n when we use square root optimization?(a) O(√n)(b) O(n)(c) O(1)(d) O(n^2)The question was posed to me by my school teacher while I was bunking the class.I need to ask this question from Miscellaneous in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» The correct option is (C) O(1) |
|
| 7. |
Total how many iterations are required to find the sum of elements in a given range of (l,r) in an array of size n when we use square root optimization?(a) √n(b) 2*√n(c) 3*√n(d) n*√nThis question was posed to me in an interview for internship.This key question is from Miscellaneous in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right choice is (c) 3*√n |
|
| 8. |
What will be the worst case time complexity of finding the sum of elements in a given range of (l,r) in an array of size n when we use square root optimization?(a) O(n)(b) O(l+r)(c) O(√n)(d) O(r-l)This question was posed to me during an interview.I need to ask this question from Miscellaneous in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct choice is (C) O(√n) |
|
| 9. |
What will be the worst case time complexity of finding the sum of elements in a given range of (l,r) in an array of size n?(a) O(n)(b) O(l+r)(c) O(l-r)(d) O(r-l)This question was addressed to me during a job interview.I need to ask this question from Miscellaneous in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) O(n) |
|
| 10. |
By what factor time complexity is reduced when we apply square root decomposition to a code?(a) n(b) √n(c) n^2(d) n^-1/2This question was addressed to me during an online exam.Origin of the question is Miscellaneous topic in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (b) √n The best EXPLANATION: In square root DECOMPOSITION a given array is DECOMPOSED into SMALL parts each of size √n. This reduces the time complexity of the code by a factor of √n. |
|
| 11. |
What is the purpose of using square root decomposition?(a) to reduce the time complexity of a code(b) to increase the space complexity of a code(c) to reduce the space complexity of a code(d) to reduce the space and time complexity of a codeThe question was posed to me in an interview for job.My question is from Miscellaneous in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» The CORRECT ANSWER is (a) to reduce the time complexity of a code |
|
| 12. |
Co-ordinate compression can only be applied in a co-ordinate system problem.(a) true(b) falseThe question was posed to me in an international level competition.Question is taken from Miscellaneous topic in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (B) false |
|
| 13. |
Co-ordinate compression reduces the number of squares in a graph.(a) true(b) falseThe question was posed to me in semester exam.The origin of the question is Miscellaneous topic in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right choice is (a) true |
|
| 14. |
What is the need for co-ordinate compression?(a) for improving time complexity(b) for improving space complexity(c) for improving both time and space complexity(d) for making code simplerThe question was asked by my college director while I was bunking the class.This key question is from Miscellaneous in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» The correct choice is (c) for improving both time and space complexity |
|
| 15. |
What is co-ordinate compression?(a) process of reassigning co-ordinates to remove gaps(b) inserting gaps in a co-ordinate system(c) removing redundant co-ordinates(d) adding extra gapsI have been asked this question in semester exam.This interesting question is from Miscellaneous in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (a) process of REASSIGNING co-ordinates to REMOVE GAPS |
|
| 16. |
What is the best case time complexity of quickselect?(a) O(n log n)(b) O(n^2)(c) O(n)(d) O(log n)I got this question in final exam.This is a very interesting question from Miscellaneous in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (c) O(n) |
|
| 17. |
Quickselect is an in-place algorithm?(a) true(b) falseI had been asked this question in an interview.This interesting question is from Miscellaneous in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» RIGHT option is (a) true To EXPLAIN: QUICKSELECT’s AUXILIARY space requirement is O(1). So quickselect qualifies as an in-place ALGORITHM. |
|
| 18. |
What is the auxiliary space requirement of the quickselect algorithm?(a) O(n^2)(b) O(n)(c) O(n log n)(d) O(1)This question was addressed to me in examination.I want to ask this question from Miscellaneous topic in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct choice is (d) O(1) |
|
| 19. |
What will be the output if quickselect algorithm is applied to the array arr={1,5,4,3,7} with k given as 4?(a) 1(b) 3(c) 4(d) 5I had been asked this question in an international level competition.This intriguing question comes from Miscellaneous in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct choice is (d) 5 |
|
| 20. |
Quickselect is an example of ___________(a) sorting algorithm(b) selection algorithm(c) greedy algorithm(d) searching algorithmThe question was asked during a job interview.I need to ask this question from Miscellaneous topic in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» RIGHT choice is (B) selection algorithm Explanation: QUICKSELECT is an EXAMPLE of a selection algorithm. It finds the kth smallest element from the given list. |
|
| 21. |
Which of the following is an alternative name of the quickselect algorithm?(a) quick sort(b) hoare’s selection algorithm(c) tony’s selection algorithm(d) kruskal’s algorithmI have been asked this question during an interview for a job.The query is from Miscellaneous in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» The correct option is (B) hoare’s selection algorithm |
|
| 22. |
When the topological sort of a graph is unique?(a) When there exists a hamiltonian path in the graph(b) In the presence of multiple nodes with indegree 0(c) In the presence of single node with indegree 0(d) In the presence of single node with outdegree 0I have been asked this question during a job interview.My question comes from Topological Sort topic in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right answer is (a) When there exists a hamiltonian PATH in the graph |
|
| 23. |
A man wants to go different places in the world. He has listed them down all. But there are some places where he wants to visit before some other places. What application of graph can he use to determine that?(a) Depth First Search(b) Breadth First Search(c) Topological Sorting(d) Dijkstra’s Shortest path algorithmI had been asked this question during a job interview.This interesting question is from Topological Sort topic in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right choice is (c) TOPOLOGICAL Sorting |
|
| 24. |
Topological sort is equivalent to which of the traversals in trees?(a) Pre-order traversal(b) Post-order traversal(c) In-order traversal(d) Level-order traversalThis question was posed to me by my college professor while I was bunking the class.Asked question is from Topological Sort in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) Pre-order traversal |
|
| 25. |
Topological sort can be implemented by?(a) Using Depth First Search(b) Using Breadth First Search(c) Using Depth and Breadth First Search(d) Using level ordered searchI got this question in semester exam.I would like to ask this question from Topological Sort in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right option is (c) Using Depth and Breadth First Search |
|
| 26. |
Topological sort of a Directed Acyclic graph is?(a) Always unique(b) Always Not unique(c) Sometimes unique and sometimes not unique(d) Always unique if graph has even number of verticesThe question was posed to me during an interview for a job.I'm obligated to ask this question of Topological Sort in chapter Miscellaneous of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (C) Sometimes unique and sometimes not unique To explain: The topological SORT of a graph can be unique if we assume the graph as a single linked list and we can have multiple topological sort ORDER if we consider a graph as a complete binary tree. |
|
| 27. |
Which of the following is not an application of topological sorting?(a) Finding prerequisite of a task(b) Finding Deadlock in an Operating System(c) Finding Cycle in a graph(d) Ordered StatisticsI have been asked this question during an online interview.I'm obligated to ask this question of Topological Sort topic in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» Right choice is (d) Ordered Statistics |
|
| 28. |
In most of the cases, topological sort starts from a node which has __________(a) Maximum Degree(b) Minimum Degree(c) Any degree(d) Zero DegreeI have been asked this question during an online exam.Enquiry is from Topological Sort in portion Miscellaneous of Data Structures & Algorithms II |
|
Answer» The CORRECT OPTION is (d) Zero DEGREE |
|
| 29. |
Most Efficient Time Complexity of Topological Sorting is? (V – number of vertices, E – number of edges)(a) O(V + E)(b) O(V)(c) O(E)(d) O(V*E)The question was asked in a job interview.This intriguing question comes from Topological Sort topic in division Miscellaneous of Data Structures & Algorithms II |
|
Answer» The correct choice is (a) O(V + E) |
|
| 30. |
Topological sort can be applied to which of the following graphs?(a) Undirected Cyclic Graphs(b) Directed Cyclic Graphs(c) Undirected Acyclic Graphs(d) Directed Acyclic GraphsI have been asked this question during a job interview.The doubt is from Topological Sort topic in section Miscellaneous of Data Structures & Algorithms II |
|
Answer» Correct answer is (d) DIRECTED ACYCLIC Graphs |
|