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 formula to compute the transitive closure of a graph?(a) tij(k) = tij(k-1) AND (tik(k-1) OR tkj(k-1))(b) tij(k) = tij(k-1) OR (tik(k-1) AND tkj(k-1))(c) tij(k) = tij(k-1) AND (tik(k-1) AND tkj(k-1))(d) tij(k) = tij(k-1) OR (tik(k-1) OR tkj(k-1))The question was posed to me in unit test.This intriguing question comes from Shortest Path topic in section Shortest Path of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (b) TIJ(k) = tij(k-1) OR (TIK(k-1) AND tkj(k-1)) Explanation: TRANSITIVE closure of a graph can be computed by using Floyd Warshall algorithm. This method involves substitution of logical operations (logical OR and logical AND) for arithmetic operations min and + in Floyd Warshall Algorithm. Floyd Warshall Algorithm: dij(k)=min(dij(k-1), dik(k-1) + dkj(k-1)) Transitive closure: tij(k)= tij(k-1) OR (tik(k-1) AND tkj(k-1)). |
|
| 2. |
In the given graph, how many intermediate vertices are required to travel from node a to node e at a minimum cost?(a) 2(b) 0(c) 1(d) 3The question was asked in exam.I need to ask this question from Shortest Path in division Shortest Path of Data Structures & Algorithms II |
|
Answer» Right choice is (C) 1 |
|
| 3. |
In the given graph, what is the minimum cost to travel from vertex 1 to vertex 3?(a) 3(b) 2(c) 10(d) -3The question was asked during an online exam.My question is taken from Shortest Path in section Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct choice is (d) -3 |
|
| 4. |
The time taken to compute the transitive closure of a graph is Theta(n^2).(a) True(b) FalseI have been asked this question in final exam.Asked question is from Shortest Path topic in section Shortest Path of Data Structures & Algorithms II |
|
Answer» Right choice is (B) False |
|
| 5. |
Using logical operator’s instead arithmetic operators saves time and space.(a) True(b) FalseI got this question in quiz.This key question is from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» The correct choice is (a) True |
|
| 6. |
What happens when the value of k is 0 in the Floyd Warshall Algorithm?(a) 1 intermediate vertex(b) 0 intermediate vertex(c) N intermediate vertices(d) N-1 intermediate verticesThis question was addressed to me during an online exam.My query is from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» RIGHT CHOICE is (b) 0 intermediate vertex Easiest explanation - When k=0, a path from vertex i to vertex j has no intermediate vertices at all. Such a path has at most one edge and HENCE dij(0) = wij. |
|
| 7. |
Who proposed the modern formulation of Floyd-Warshall Algorithm as three nested loops?(a) Robert Floyd(b) Stephen Warshall(c) Bernard Roy(d) Peter IngermanThe question was asked during an internship interview.Query is from Shortest Path topic in section Shortest Path of Data Structures & Algorithms II |
|
Answer» RIGHT option is (d) PETER Ingerman The best I can explain: The modern formulation of Floyd-Warshall Algorithm as three NESTED for-loops was proposed by Peter Ingerman in the YEAR 1962. |
|
| 8. |
Floyd- Warshall algorithm was proposed by ____________(a) Robert Floyd and Stephen Warshall(b) Stephen Floyd and Robert Warshall(c) Bernad Floyd and Robert Warshall(d) Robert Floyd and Bernad WarshallThe question was asked in semester exam.This question is from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» The CORRECT answer is (a) Robert Floyd and Stephen Warshall |
|
| 9. |
What procedure is being followed in Floyd Warshall Algorithm?(a) Top down(b) Bottom up(c) Big bang(d) SandwichI had been asked this question in a job interview.This interesting question is from Shortest Path in section Shortest Path of Data Structures & Algorithms II |
|
Answer» Right answer is (B) Bottom up |
|
| 10. |
Floyd Warshall Algorithm can be used for finding _____________(a) Single source shortest path(b) Topological sort(c) Minimum spanning tree(d) Transitive closureThe question was posed to me in homework.My doubt stems from Shortest Path topic in chapter Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct answer is (d) Transitive closure |
|
| 11. |
What approach is being followed in Floyd Warshall Algorithm?(a) Greedy technique(b) Dynamic Programming(c) Linear Programming(d) BacktrackingI got this question in semester exam.I want to ask this question from Shortest Path in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» The CORRECT answer is (b) DYNAMIC Programming |
|
| 12. |
What is the running time of the Floyd Warshall Algorithm?(a) Big-oh(V)(b) Theta(V^2)(c) Big-Oh(VE)(d) Theta(V^3)I got this question during an interview.I want to ask this question from Shortest Path topic in section Shortest Path of Data Structures & Algorithms II |
|
Answer» Right ANSWER is (d) Theta(V^3) |
|
| 13. |
Floyd Warshall’s Algorithm can be applied on __________(a) Undirected and unweighted graphs(b) Undirected graphs(c) Directed graphs(d) Acyclic graphsThis question was posed to me in an online interview.This intriguing question comes from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» Right CHOICE is (c) Directed graphs |
|
| 14. |
Floyd Warshall’s Algorithm is used for solving ____________(a) All pair shortest path problems(b) Single Source shortest path problems(c) Network flow problems(d) Sorting problemsI got this question in exam.This intriguing question originated from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» RIGHT answer is (a) All pair shortest path PROBLEMS The explanation is: Floyd WARSHALL’s ALGORITHM is used for solving all pair shortest path problems. It means the algorithm is used for finding the shortest PATHS between all pairs of vertices in a graph. |
|
| 15. |
A graph is said to have a negative weight cycle when?(a) The graph has 1 negative weighted edge(b) The graph has a cycle(c) The total weight of the graph is negative(d) The graph has 1 or more negative weighted edgesI had been asked this question during an interview.This is a very interesting question from Shortest Path topic in chapter Shortest Path of Data Structures & Algorithms II |
|
Answer» The correct ANSWER is (c) The total WEIGHT of the graph is negative |
|
| 16. |
Bellmann Ford Algorithm is an example for ____________(a) Dynamic Programming(b) Greedy Algorithms(c) Linear Programming(d) Branch and BoundI have been asked this question in final exam.My question is taken from Shortest Path in chapter Shortest Path of Data Structures & Algorithms II |
|
Answer» CORRECT OPTION is (a) Dynamic Programming For EXPLANATION: In Bellmann Ford Algorithm the SHORTEST paths are calculated in bottom up manner which is similar to other dynamic programming problems. |
|
| 17. |
In the given graph, identify the path that has minimum cost to travel from node a to node f.(a) a-b-c-f(b) a-d-e-f(c) a-d-b-c-f(d) a-d-b-c-e-fThe question was posed to me in exam.This intriguing question comes from Shortest Path in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» The CORRECT choice is (d) a-d-b-c-e-f |
|
| 18. |
Consider the following graph. What is the minimum cost to travel from node A to node C?(a) 5(b) 2(c) 1(d) 3The question was posed to me in an online quiz.Question is from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» The correct choice is (b) 2 |
|
| 19. |
Bellmann Ford algorithm was first proposed by ________(a) Richard Bellmann(b) Alfonso Shimbe(c) Lester Ford Jr(d) Edward F. MooreI got this question in an interview for internship.This interesting question is from Shortest Path topic in chapter Shortest Path of Data Structures & Algorithms II |
|
Answer» Right answer is (b) ALFONSO Shimbe |
|
| 20. |
Bellmann Ford Algorithm can be applied for _____________(a) Undirected and weighted graphs(b) Undirected and unweighted graphs(c) Directed and weighted graphs(d) All directed graphsI got this question in an interview for job.I need to ask this question from Shortest Path topic in section Shortest Path of Data Structures & Algorithms II |
|
Answer» Right choice is (c) Directed and weighted graphs |
|
| 21. |
How many solution/solutions are available for a graph having negative weight cycle?(a) One solution(b) Two solutions(c) No solution(d) Infinite solutionsI have been asked this question during an online exam.My doubt stems from Shortest Path in division Shortest Path of Data Structures & Algorithms II |
|
Answer» RIGHT option is (c) No solution The BEST EXPLANATION: If the graph has any negative weight cycle then the algorithm indicates that no solution EXISTS for that graph. |
|
| 22. |
Bellmann Ford algorithm is used to indicate whether the graph has negative weight cycles or not.(a) True(b) FalseI had been asked this question in an online interview.My question comes from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» RIGHT answer is (a) True Easiest explanation - Bellmann Ford algorithm returns true if the GRAPH does not have any NEGATIVE WEIGHT cycles and returns false when the graph has negative weight cycles. |
|
| 23. |
Bellmann ford algorithm provides solution for ____________ problems.(a) All pair shortest path(b) Sorting(c) Network flow(d) Single source shortest pathI had been asked this question in an online quiz.Query is from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (d) Single SOURCE shortest path |
|
| 24. |
The Bellmann Ford algorithm returns _______ value.(a) Boolean(b) Integer(c) String(d) DoubleThe question was asked in an interview.My question is taken from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» The correct CHOICE is (a) Boolean |
|
| 25. |
Dijkstra’s Algorithm is the prime example for ___________(a) Greedy algorithm(b) Branch and bound(c) Back tracking(d) Dynamic programmingI have been asked this question in an international level competition.My question is from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» Right answer is (a) Greedy algorithm |
|
| 26. |
In the given graph, identify the shortest path having minimum cost to reach vertex E if A is the source vertex.(a) a-b-e(b) a-c-e(c) a-c-d-e(d) a-c-d-b-eThe question was posed to me during an internship interview.I'm obligated to ask this question of Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (b) a-C-e |
|
| 27. |
Dijkstra’s Algorithm run on a weighted, directed graph G={V,E} with non-negative weight function w and source s, terminates with d[u]=delta(s,u) for all vertices u in V.(a) True(b) FalseThe question was posed to me by my school principal while I was bunking the class.My question is taken from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) True |
|
| 28. |
The running time of Bellmann Ford algorithm is lower than that of Dijkstra’s Algorithm.(a) True(b) FalseI have been asked this question in an interview for internship.I'd like to ask this question from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» The correct choice is (B) False |
|
| 29. |
What is running time of Dijkstra’s algorithm using Binary min- heap method?(a) O(V)(b) O(VlogV)(c) O(E)(d) O(ElogV)The question was posed to me during an internship interview.My question is taken from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct choice is (d) O(ElogV) |
|
| 30. |
The maximum number of times the decrease key operation performed in Dijkstra’s algorithm will be equal to ___________(a) Total number of vertices(b) Total number of edges(c) Number of vertices – 1(d) Number of edges – 1This question was addressed to me at a job interview.This is a very interesting question from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» CORRECT CHOICE is (b) Total number of edges Easiest explanation - If the total number of edges in all adjacency list is E, then there will be a total of E number of ITERATIONS, hence there will be a total of at most E DECREASE key OPERATIONS. |
|
| 31. |
How many times the insert and extract min operations are invoked per vertex?(a) 1(b) 2(c) 3(d) 0The question was posed to me at a job interview.Question is from Shortest Path topic in division Shortest Path of Data Structures & Algorithms II |
|
Answer» The correct choice is (a) 1 |
|
| 32. |
Dijkstra’s Algorithm is used to solve _____________ problems.(a) All pair shortest path(b) Single source shortest path(c) Network flow(d) SortingThis question was posed to me in an online quiz.My question is from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II |
|
Answer» Correct choice is (B) Single source shortest path |
|