Explore topic-wise InterviewSolutions in .

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 can traverse the state space tree only in DFS manner?(a) branch and bound(b) dynamic programming(c) greedy algorithm(d) backtrackingI got this question during a job interview.I would like to ask this question from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

Correct CHOICE is (d) backtracking

Easiest explanation - Both backtracking as well as branch and BOUND are PROBLEM solving algorithms. Branch and bound can TRAVERSE in DFS as well as BFS MANNER whereas backtracking only traverses in DFS manner.

2.

Choose the correct statement from the following.(a) branch and bound is more efficient than backtracking(b) branch and bound is not suitable where a greedy algorithm is not applicable(c) branch and bound divides a problem into at least 2 new restricted sub problems(d) backtracking divides a problem into at least 2 new restricted sub problemsI have been asked this question in final exam.My doubt stems from Graph Search in division Graph Search of Data Structures & Algorithms II

Answer»

Correct answer is (c) BRANCH and bound divides a problem into at least 2 new restricted sub problems

For EXPLANATION: Both BACKTRACKING as well as branch and bound are problem SOLVING ALGORITHMS. Branch and bound is less efficient than backtracking. Branch and bound divides a problem into at least 2 new restricted sub problems.

3.

Both LIFO branch and bound strategy and backtracking leads to depth first search.(a) true(b) falseThis question was addressed to me in my homework.I would like to ask this question from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

The correct option is (a) true

Best explanation: Both backtrackings as well as branch and bound are problem SOLVING ALGORITHMS. Both LIFO branch and bound STRATEGY and backtracking leads to depth first search.

4.

Both FIFO branch and bound strategy and backtracking leads to depth first search.(a) true(b) falseThe question was asked in an interview.The above asked question is from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

The CORRECT option is (b) false

The explanation is: FIFO branch and bound leads to breadth first search. Whereas BACKTRACKING leads to DEPTH first search.

5.

Which of the following branch and bound strategy leads to depth first search?(a) LIFO branch and bound(b) FIFO branch and bound(c) Lowest cost branch and bound(d) Highest cost branch and boundI got this question in an online interview.Question is taken from Graph Search in division Graph Search of Data Structures & Algorithms II

Answer»

Correct answer is (a) LIFO branch and BOUND

Easiest explanation - LIFO, FIFO and Lowest cost branch and bound are different strategies to GENERATE branches. LIFO branch and bound leads to depth first SEARCH.

6.

Which of the following branch and bound strategy leads to breadth first search?(a) LIFO branch and bound(b) FIFO branch and bound(c) Lowest cost branch and bound(d) Highest cost branch and boundThis question was addressed to me in an interview for job.My question comes from Graph Search topic in portion Graph Search of Data Structures & Algorithms II

Answer» CORRECT option is (b) FIFO branch and bound

Explanation: LIFO, FIFO and Lowest COST branch and bound are DIFFERENT strategies to generate branches.FIFO branch and bound leads to breadth first search.
7.

Which data structure is most suitable for implementing best first branch and bound strategy?(a) stack(b) queue(c) priority queue(d) linked listThis question was posed to me in my homework.Question is from Graph Search in division Graph Search of Data Structures & Algorithms II

Answer»

Right answer is (c) PRIORITY queue

The BEST explanation: Priority Queue is the data STRUCTURE is USED for implementing best first branch and bound strategy. Dijkstra’s ALGORITHM is an example of best first search algorithm.

8.

Which data structure is used for implementing a FIFO branch and bound strategy?(a) stack(b) queue(c) array(d) linked listI got this question in an online quiz.This intriguing question comes from Graph Search topic in section Graph Search of Data Structures & Algorithms II

Answer» CORRECT OPTION is (b) queue

For explanation: Queue is the data structure is used for implementing FIFO branch and bound strategy. This leads to breadth first search as every branch at DEPTH is explored first before moving to the nodes at greater depth.
9.

Which data structure is used for implementing a LIFO branch and bound strategy?(a) stack(b) queue(c) array(d) linked listThe question was asked in examination.I need to ask this question from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

Correct choice is (a) STACK

To explain: Stack is the DATA structure is used for implementing LIFO branch and bound strategy. This leads to depth first search as every branch is EXPLORED until a LEAF node is discovered.

10.

Which of the following is not a branch and bound strategy to generate branches?(a) LIFO branch and bound(b) FIFO branch and bound(c) Lowest cost branch and bound(d) Highest cost branch and boundI have been asked this question during a job interview.I'd like to ask this question from Graph Search in division Graph Search of Data Structures & Algorithms II

Answer»

Correct ANSWER is (d) HIGHEST cost BRANCH and bound

Easy EXPLANATION - LIFO, FIFO and Lowest cost branch and bound are different strategies to GENERATE branches. Lowest cost branch and bound helps us find the lowest cost path.

11.

Branch and bound is a __________(a) problem solving technique(b) data structure(c) sorting algorithm(d) type of treeI have been asked this question by my school principal while I was bunking the class.My enquiry is from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer» CORRECT answer is (a) problem solving TECHNIQUE

Easy explanation - Branch and bound is a problem solving technique GENERALLY USED for solving combinatorial OPTIMIZATION problems. Branch and bound helps in solving them faster.
12.

Who published the B* search algorithm?(a) Peter Hart(b) Nils Nilsson(c) Bertram Raphael(d) Hans BerlinerI got this question in unit test.This is a very interesting question from Graph Search in section Graph Search of Data Structures & Algorithms II

Answer» RIGHT option is (d) HANS Berliner

Easiest explanation - Hans Berliner was a Computer Science professor who first PUBLISHED the B* search algorithm in 1979. While Peter HART Nils Nilsson Bertram Raphael are the three scientists of SRI International who first published the A* search algorithm which uses heuristics for better PERFORMANCE.
13.

Which of the following scientists didn’t publish A* algorithm?(a) Peter Hart(b) Nils Nilsson(c) Bertram Raphael(d) Hans BerlinerThe question was posed to me at a job interview.Query is from Graph Search topic in division Graph Search of Data Structures & Algorithms II

Answer»

Right choice is (d) Hans BERLINER

To EXPLAIN: PETER Hart Nils Nilsson Bertram RAPHAEL are the three scientists of SRI International who first published the A* search algorithm which uses heuristics for better performance. Hans Berliner published B* algorithm.

14.

Which of the following is the greedy best first search?(a) Pure Heuristic Search(b) A*(c) B*(d) Both A* and B*This question was addressed to me in quiz.The doubt is from Graph Search topic in section Graph Search of Data Structures & Algorithms II

Answer» CORRECT choice is (a) Pure HEURISTIC Search

Easiest EXPLANATION - Pure Heuristic Search is also called GREEDY best first search while A* and B* search algorithms are not greedy best first search.
15.

Which of the following is an example of Best First Search algorithm?(a) A*(b) B*(c) C*(d) Both A* and B*I got this question by my school teacher while I was bunking the class.Origin of the question is Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer» CORRECT answer is (d) Both A* and B*

Explanation: In computer SCIENCE, A* algorithm is used in graph TRAVERSAL and path finding. It is a process of node finding in between a path. B* algorithm is used to FIND the LEAST cost path between the source node and the destination node.
16.

Which algorithm is used to find the least cost path from source node to destination node?(a) A* BFS(b) C* BFS(c) D* BFS(d) B* BFSThis question was posed to me in an interview for internship.My enquiry is from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

Right choice is (d) B* BFS

The best I can EXPLAIN: In computer SCIENCE, B* algorithm is USED to find the least cost path between the SOURCE node and the destination node. It is an example of the best first search.

17.

Which algorithm is used in graph traversal and path finding?(a) A*(b) C*(c) D*(d) E*This question was posed to me during an online exam.My doubt is from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

Right option is (a) A*

Explanation: In computer SCIENCE A* ALGORITHM is USED in graph traversal and path finding. It is a process of node finding in between a path. It is an EXAMPLE of the best first SEARCH.

18.

What is the other name of the greedy best first search?(a) Heuristic Search(b) Pure Heuristic Search(c) Combinatorial Search(d) Divide and Conquer SearchThe question was posed to me during an interview.I want to ask this question from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

The CORRECT choice is (b) Pure Heuristic Search

For explanation: The GREEDY best FIRST search algorithm was used to predict the closeness of the end of the path and its solution by some of the computer scientists. It is ALSO KNOWN as Pure Heuristic Search.

19.

Which type of best first search algorithm was used to predict the closeness of the end of path and its solution?(a) Greedy BFS(b) Divide and Conquer(c) Heuristic BFS(d) CombinatorialThe question was posed to me in an interview.My question is based upon Graph Search topic in portion Graph Search of Data Structures & Algorithms II

Answer»

Correct choice is (a) Greedy BFS

The EXPLANATION is: The greedy best first search algorithm was USED to predict the closeness of the end of the path and its SOLUTION by some of the computer SCIENTISTS.

20.

Who described this Best First Search algorithm using heuristic evaluation rule?(a) Judea Pearl(b) Max Bezzel(c) Franz Nauck(d) Alan TuringI have been asked this question during a job interview.My doubt stems from Graph Search topic in portion Graph Search of Data Structures & Algorithms II

Answer»

Correct choice is (a) Judea Pearl

Easiest explanation - The BEST FIRST search algorithm using heuristic evaluation RULE or FUNCTION was proposed by an Israeli – American computer SCIENTIST and philosopher Judea Pearl.

21.

Is Best First Search a searching algorithm used in graphs.(a) True(b) FalseThis question was posed to me by my college professor while I was bunking the class.My doubt is from Graph Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

Right choice is (a) True

To explain: Best First SEARCH is a searching algorithm used in GRAPHS. It explores it by choosing a NODE by heuristic EVALUATION rule. It is used in solving searching for related PROBLEMS.

22.

In BFS, how many times a node is visited?(a) Once(b) Twice(c) Equivalent to number of indegree of the node(d) ThriceThis question was posed to me during an interview.This key question is from Breadth First Search topic in section Graph Search of Data Structures & Algorithms II

Answer»

The correct answer is (c) Equivalent to number of INDEGREE of the node

Easiest EXPLANATION - In BREADTH FIRST Search, we have to see whether the node is visited or not by it’s ancestor. If it is visited, we won’t let it enter it in the queue.

23.

Regarding implementation of Breadth First Search using queues, what is the maximum distance between two nodes present in the queue? (considering each edge length 1)(a) Can be anything(b) 0(c) At most 1(d) Insufficient InformationThis question was addressed to me in class test.This intriguing question comes from Breadth First Search topic in division Graph Search of Data Structures & Algorithms II

Answer»

Right option is (c) At most 1

For explanation: In the queue, at a time, only those nodes will be there WHOSE difference among levels is 1. Same as LEVEL order TRAVERSAL of the TREE.

24.

When the Breadth First Search of a graph is unique?(a) When the graph is a Binary Tree(b) When the graph is a Linked List(c) When the graph is a n-ary Tree(d) When the graph is a Ternary TreeThe question was asked by my school principal while I was bunking the class.My question is taken from Breadth First Search topic in portion Graph Search of Data Structures & Algorithms II

Answer»

The correct answer is (b) When the graph is a LINKED List

Explanation: When EVERY node will have one successor then the Breadth First Search is UNIQUE. In all other cases, when it will have more than one successor, it can choose any of them in arbitrary order.

25.

Which of the following is not an application of Breadth First Search?(a) Finding shortest path between two nodes(b) Finding bipartiteness of a graph(c) GPS navigation system(d) Path FindingI got this question in a national level competition.Question is taken from Breadth First Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

Right choice is (d) Path Finding

Explanation: BREADTH FIRST Search can be applied to Bipartite a GRAPH, to find the shortest path between two nodes, in GPS Navigation. In Path finding, Depth First Search is used.

26.

A person wants to visit some places. He starts from a vertex and then wants to visit every place connected to this vertex and so on. What algorithm he should use?(a) Depth First Search(b) Breadth First Search(c) Trim’s algorithm(d) Kruskal’s algorithmThe question was posed to me in an international level competition.My doubt stems from Breadth First Search in division Graph Search of Data Structures & Algorithms II

Answer»

Right answer is (b) Breadth FIRST SEARCH

Explanation: This is the DEFINITION of the Breadth First Search. Exploring a NODE, then it’s neighbors and so on.

27.

The Breadth First Search traversal of a graph will result into?(a) Linked List(b) Tree(c) Graph with back edges(d) ArraysThe question was posed to me by my school teacher while I was bunking the class.My question is taken from Breadth First Search in section Graph Search of Data Structures & Algorithms II

Answer»

Correct CHOICE is (b) TREE

Explanation: The Breadth FIRST Search will make a GRAPH which don’t have BACK edges (a tree) which is known as Breadth First Tree.

28.

The Data structure used in standard implementation of Breadth First Search is?(a) Stack(b) Queue(c) Linked List(d) TreeI have been asked this question during an internship interview.Query is from Breadth First Search in portion Graph Search of Data Structures & Algorithms II

Answer»

The correct answer is (b) QUEUE

The explanation is: The Breadth First Search explores every NODE once and PUT that node in queue and then it takes out NODES from the queue and explores it’s neighbors.

29.

Time Complexity of Breadth First Search is? (V – number of vertices, E – number of edges)(a) O(V + E)(b) O(V)(c) O(E)(d) O(V*E)I got this question during an interview.My question is from Breadth First Search topic in division Graph Search of Data Structures & Algorithms II

Answer»

Correct answer is (a) O(V + E)

Best explanation: The Breadth FIRST Search EXPLORES every NODE once and every EDGE once (in worst case), so it’s time COMPLEXITY is O(V + E).

30.

Breadth First Search is equivalent to which of the traversal in the Binary Trees?(a) Pre-order Traversal(b) Post-order Traversal(c) Level-order Traversal(d) In-order TraversalI have been asked this question during a job interview.Question is from Breadth First Search topic in chapter Graph Search of Data Structures & Algorithms II

Answer»

The correct CHOICE is (c) Level-order Traversal

Explanation: The Breadth First Search Algorithm SEARCHES the nodes on the basis of level. It TAKES a node (level 0), explores it’s NEIGHBORS (level 1) and so on.

31.

Choose the incorrect statement about DFS and BFS from the following?(a) BFS is equivalent to level order traversal in trees(b) DFS is equivalent to post order traversal in trees(c) DFS and BFS code has the same time complexity(d) BFS is implemented using queueThis question was posed to me in final exam.Query is from Non-recursive Depth First Search in chapter Graph Search of Data Structures & Algorithms II

Answer»

The correct ANSWER is (b) DFS is equivalent to post order traversal in trees

The best I can explain: DFS is equivalent to PRE order traversal in trees, not post order traversal. It is so because in DFS we KEEP on exploring as far as possible along each BRANCH before backtracking. So it should be equivalent to pre order traversal.

32.

In Depth First Search, how many times a node is visited?(a) Once(b) Twice(c) Equivalent to number of indegree of the node(d) ThriceThis question was addressed to me during an interview for a job.My doubt is from Depth First Search in division Graph Search of Data Structures & Algorithms II

Answer»

Correct option is (c) Equivalent to number of INDEGREE of the node

To EXPLAIN: In DEPTH First Search, we have to see WHETHER the node is visited or not by it’s ancestor. If it is visited, we won’t LET it enter it in the stack.

33.

Regarding implementation of Depth First Search using stacks, what is the maximum distance between two nodes present in the stack? (considering each edge length 1)(a) Can be anything(b) 0(c) At most 1(d) Insufficient InformationThe question was posed to me during an interview for a job.Question is taken from Depth First Search topic in division Graph Search of Data Structures & Algorithms II

Answer»

The correct OPTION is (a) Can be anything

The best I can explain: In the stack, at a time, there can be nodes which can DIFFER in many levels. So, it can be the MAXIMUM distance between TWO nodes in the GRAPH.

34.

When the Depth First Search of a graph is unique?(a) When the graph is a Binary Tree(b) When the graph is a Linked List(c) When the graph is a n-ary Tree(d) When the graph is a ternary TreeThis question was addressed to me in a national level competition.The above asked question is from Depth First Search in portion Graph Search of Data Structures & Algorithms II

Answer»

Correct choice is (b) When the graph is a Linked List

To EXPLAIN: When Every node will have one successor then the Depth First Search is UNIQUE. In all other cases, when it will have more than one successor, it can choose any of them in ARBITRARY order.

35.

Which of the following is not an application of Depth First Search?(a) For generating topological sort of a graph(b) For generating Strongly Connected Components of a directed graph(c) Detecting cycles in the graph(d) Peer to Peer NetworksThis question was posed to me by my college director while I was bunking the class.This intriguing question originated from Depth First Search in section Graph Search of Data Structures & Algorithms II

Answer»

Right CHOICE is (d) Peer to Peer Networks

The best explanation: Depth First Search is USED in the Generation of topological SORTING, Strongly CONNECTED COMPONENTS of a directed graph and to detect cycles in the graph. Breadth First Search is used in peer to peer networks to find all neighbourhood nodes.

36.

A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use?(a) Depth First Search(b) Breadth First Search(c) Trim’s algorithm(d) Kruskal’s AlgorithmThis question was addressed to me during an online exam.My doubt stems from Depth First Search in division Graph Search of Data Structures & Algorithms II

Answer»

Right answer is (a) Depth First Search

Explanation: This is the definition of the Depth First Search. Exploring a node, then AGGRESSIVELY finding nodes TILL it is not able to FIND any node.

37.

The Depth First Search traversal of a graph will result into?(a) Linked List(b) Tree(c) Graph with back edges(d) ArrayI have been asked this question in final exam.I want to ask this question from Depth First Search in chapter Graph Search of Data Structures & Algorithms II

Answer» RIGHT CHOICE is (b) Tree

Explanation: The DEPTH First Search will make a GRAPH which don’t have back EDGES (a tree) which is known as Depth First Tree.
38.

Time Complexity of DFS 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 an interview for job.This question is from Depth First Search topic in chapter Graph Search of Data Structures & Algorithms II

Answer»

The correct choice is (a) O(V + E)

To EXPLAIN: The DEPTH First Search EXPLORES every node once and every edge once (in worst case), so it’s time complexity is O(V + E).

39.

The Data structure used in standard implementation of Breadth First Search is?(a) Stack(b) Queue(c) Linked List(d) TreeThe question was posed to me in semester exam.Question is from Depth First Search topic in chapter Graph Search of Data Structures & Algorithms II

Answer»

The correct option is (a) Stack

The explanation is: The Depth FIRST SEARCH is implemented using recursion. So, stack can be used as DATA STRUCTURE to implement depth first search.

40.

Depth First Search is equivalent to which of the traversal in the Binary Trees?(a) Pre-order Traversal(b) Post-order Traversal(c) Level-order Traversal(d) In-order TraversalI got this question in final exam.This is a very interesting question from Depth First Search in section Graph Search of Data Structures & Algorithms II

Answer» CORRECT choice is (a) Pre-order Traversal

Easy explanation - In Depth First SEARCH, we EXPLORE all the nodes aggressively to ONE path and then BACKTRACK to the node. Hence, it is equivalent to the pre-order traversal of a Binary Tree.