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. |
Which of the following is false about Prim’s algorithm?(a) It is a greedy algorithm(b) It constructs MST by selecting edges in increasing order of their weights(c) It never accepts cycles in the MST(d) It can be implemented using the Fibonacci heapThe question was posed to me in an interview for internship.I want to ask this question from Minimum Spanning Tree in chapter Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Correct choice is (b) It constructs MST by SELECTING edges in INCREASING order of their weights |
|
| 2. |
Prim’s algorithm can be efficiently implemented using _____ for graphs with greater density.(a) d-ary heap(b) linear search(c) fibonacci heap(d) binary searchThis question was posed to me during an online exam.Query is from Minimum Spanning Tree topic in chapter Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct answer is (a) d-ary heap |
|
| 3. |
Prim’s algorithm is also known as __________(a) Dijkstra–Scholten algorithm(b) Borůvka’s algorithm(c) Floyd–Warshall algorithm(d) DJP AlgorithmThe question was posed to me during an interview for a job.My doubt stems from Minimum Spanning Tree in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct option is (d) DJP ALGORITHM |
|
| 4. |
Kruskal’s algorithm is best suited for the sparse graphs than the prim’s algorithm.(a) True(b) FalseThe question was posed to me at a job interview.Asked question is from Minimum Spanning Tree topic in portion Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» CORRECT choice is (a) True For EXPLANATION: Prim’s algorithm and Kruskal’s algorithm perform equally in case of the sparse graphs. But Kruskal’s algorithm is simpler and EASY to work with. So, it is BEST suited for sparse graphs. |
|
| 5. |
Prim’s algorithm resemblesDijkstra’s algorithm.(a) True(b) FalseI had been asked this question in quiz.Question is from Minimum Spanning Tree in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (a) True Best EXPLANATION: In Prim’s ALGORITHM, the MST is CONSTRUCTED starting from a single vertex and adding in new edges to the MST that link the partial tree to a new vertex outside of the MST. And Dijkstra’s algorithm also rely on the SIMILAR approach of finding the next closest vertex. So, Prim’s algorithm resembles Dijkstra’s algorithm. |
|
| 6. |
Prim’s algorithm is a ______(a) Divide and conquer algorithm(b) Greedy algorithm(c) Dynamic Programming(d) Approximation algorithmI got this question in class test.My question is taken from Minimum Spanning Tree in chapter Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct CHOICE is (b) Greedy algorithm |
|
| 7. |
Worst case is the worst case time complexity of Prim’s algorithm if adjacency matrix is used?(a) O(log V)(b) O(V^2)(c) O(E^2)(d) O(V log E)I had been asked this question during an interview.Query is from Minimum Spanning Tree topic in portion Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right answer is (b) O(V^2) |
|
| 8. |
Which of the following is true?(a) Prim’s algorithm initialises with a vertex(b) Prim’s algorithm initialises with a edge(c) Prim’s algorithm initialises with a vertex which has smallest edge(d) Prim’s algorithm initialises with a forestThis question was addressed to me in examination.Origin of the question is Minimum Spanning Tree in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right ANSWER is (a) Prim’s algorithm initialises with a VERTEX |
|
| 9. |
Kruskal’s algorithm is best suited for the dense graphs than the prim’s algorithm.(a) True(b) FalseI have been asked this question by my college professor while I was bunking the class.Question is from Minimum Spanning Tree in section Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct CHOICE is (B) False |
|
| 10. |
Which of the following is false about the Kruskal’s algorithm?(a) It is a greedy algorithm(b) It constructs MST by selecting edges in increasing order of their weights(c) It can accept cycles in the MST(d) It uses union-find data structureThe question was posed to me in unit test.Question is from Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right answer is (C) It can accept cycles in the MST |
|
| 11. |
Which of the following is true?(a) Prim’s algorithm can also be used for disconnected graphs(b) Kruskal’s algorithm can also run on the disconnected graphs(c) Prim’s algorithm is simpler than Kruskal’s algorithm(d) In Kruskal’s sort edges are added to MST in decreasing order of their weightsI got this question in exam.I want to ask this question from Minimum Spanning Tree in section Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (b) Kruskal’s algorithm can also run on the DISCONNECTED GRAPHS |
|
| 12. |
Which of the following edges form minimum spanning tree on the graph using kruskals algorithm?(a) (B-E)(G-E)(E-F)(D-F)(b) (B-E)(G-E)(E-F)(B-G)(D-F)(c) (B-E)(G-E)(E-F)(D-E)(d) (B-E)(G-E)(E-F)(D-F)(D-G)The question was posed to me in unit test.My enquiry is from Minimum Spanning Tree topic in chapter Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» CORRECT ANSWER is (a) (B-E)(G-E)(E-F)(D-F) For explanation: Using Krushkal’s algorithm on the given graph, the generated minimum spanning TREE is SHOWN below. So, the edges in the MST are, (B-E)(G-E)(E-F)(D-F). |
|
| 13. |
Consider the following graph. Using Kruskal’s algorithm, which edge will be selected first?(a) GF(b) DE(c) BE(d) BGThis question was addressed to me in an internship interview.This intriguing question comes from Minimum Spanning Tree topic in section Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (c) BE |
|
| 14. |
What is the time complexity of Kruskal’s algorithm?(a) O(log V)(b) O(E log V)(c) O(E^2)(d) O(V log E)This question was addressed to me in a national level competition.This key question is from Minimum Spanning Tree in section Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Correct answer is (b) O(E LOG V) |
|
| 15. |
Kruskal’s algorithm is a ______(a) divide and conquer algorithm(b) dynamic programming algorithm(c) greedy algorithm(d) approximation algorithmThis question was posed to me in an online quiz.I want to ask this question from Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right OPTION is (c) greedy algorithm |
|
| 16. |
Kruskal’s algorithm is used to ______(a) find minimum spanning tree(b) findsingle source shortest path(c) find all pair shortest path algorithm(d) traverse the graphThe question was posed to me by my college director while I was bunking the class.This interesting question is from Minimum Spanning Tree in portion Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) find minimum SPANNING tree |
|
| 17. |
Which of the following is false?(a) The spanning trees do not have any cycles(b) MST have n – 1 edges if the graph has n edges(c) Edge e belonging to a cut of the graph if has the weight smaller than any other edge in the same cut, then the edge e is present in all the MSTs of the graph(d) Removing one edge from the spanning tree will not make the graph disconnectedThe question was posed to me in exam.My question is based upon Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Correct answer is (d) Removing one edge from the spanning tree will not make the graph disconnected |
|
| 18. |
Which of the following is not the algorithm to find the minimum spanning tree of the given graph?(a) Boruvka’s algorithm(b) Prim’s algorithm(c) Kruskal’s algorithm(d) Bellman–Ford algorithmI had been asked this question in final exam.My question comes from Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right answer is (d) Bellman–Ford algorithm |
|
| 19. |
Consider the graph shown below. Which of the following are the edges in the MST of the given graph?(a) (a-c)(c-d)(d-b)(d-b)(b) (c-a)(a-d)(d-b)(d-e)(c) (a-d)(d-c)(d-b)(d-e)(d) (c-a)(a-d)(d-c)(d-b)(d-e)The question was posed to me during a job interview.This question is from Minimum Spanning Tree in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (c) (a-d)(d-c)(d-b)(d-e) |
|
| 20. |
If all the weights of the graph are positive, then the minimum spanning tree of the graph is a minimum cost subgraph.(a) True(b) FalseThe question was posed to me in an online interview.My query is from Minimum Spanning Tree in portion Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct answer is (a) True |
|
| 21. |
Consider a undirected graph G with vertices { A, B, C, D, E}. In graph G, every edge has distinct weight. Edge CD is edge with minimum weight and edge AB is edge with maximum weight. Then, which of the following is false?(a) Every minimum spanning tree of G must contain CD(b) If AB is in a minimum spanning tree, then its removal must disconnect G(c) No minimum spanning tree contains AB(d) G has a unique minimum spanning treeI have been asked this question in an international level competition.Question is taken from Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right option is (c) No minimum spanning tree contains AB |
|
| 22. |
Consider the graph M with 3 vertices. Its adjacency matrix is shown below. Which of the following is true?(a) Graph M has no minimum spanning tree(b) Graph M has a unique minimum spanning trees of cost 2(c) Graph M has 3 distinct minimum spanning trees, each of cost 2(d) Graph M has 3 spanning trees of different costsThe question was asked in an interview for internship.My question comes from Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The CORRECT option is (c) Graph M has 3 DISTINCT MINIMUM spanning trees, each of cost 2 |
|
| 23. |
The travelling salesman problem can be solved using _________(a) A spanning tree(b) A minimum spanning tree(c) Bellman – Ford algorithm(d) DFS traversalI have been asked this question in class test.The query is from Minimum Spanning Tree topic in division Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The correct choice is (b) A minimum spanning TREE |
|
| 24. |
Consider a complete graph G with 4 vertices. The graph G has ____ spanning trees.(a) 15(b) 8(c) 16(d) 13I got this question during an interview for a job.The query is from Minimum Spanning Tree in portion Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Right option is (c) 16 |
|
| 25. |
Every graph has only one minimum spanning tree.(a) True(b) FalseI have been asked this question in an interview for job.My question is based upon Minimum Spanning Tree topic in portion Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (b) False |
|
| 26. |
Which of the following is false in the case of a spanning tree of a graph G?(a) It is tree that spans G(b) It is a subgraph of the G(c) It includes every vertex of the G(d) It can be either cyclic or acyclicThis question was addressed to me in final exam.My query is from Minimum Spanning Tree in chapter Minimum Spanning Tree of Data Structures & Algorithms II |
|
Answer» Correct option is (d) It can be either cyclic or acyclic |
|