Q. Which of the following problems can be solved using recursion?
A.
Finding the maximum element in an array
B.
Calculating the factorial of a number
C.
Sorting an array
D.
All of the above
Show solution
Solution
All of the above problems can be solved using recursion.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following statements is true about BFS?
A.
BFS can be implemented using a stack.
B.
BFS is not suitable for finding shortest paths.
C.
BFS explores nodes level by level.
D.
BFS is faster than DFS in all cases.
Show solution
Solution
BFS explores nodes level by level, making it suitable for finding the shortest path in unweighted graphs.
Correct Answer:
C
— BFS explores nodes level by level.
Learn More →
Q. Which of the following statements is true about the Bellman-Ford algorithm?
A.
It can handle negative weight edges
B.
It is faster than Dijkstra's algorithm for all graphs
C.
It only works on directed graphs
D.
It cannot detect negative weight cycles
Show solution
Solution
The Bellman-Ford algorithm can handle graphs with negative weight edges and can also detect negative weight cycles.
Correct Answer:
A
— It can handle negative weight edges
Learn More →
Q. Which operator is used to access the value at the address stored in a pointer?
Show solution
Solution
The '*' operator is used to dereference a pointer and access the value at the address it points to.
Correct Answer:
B
— *
Learn More →
Q. Which traversal method can be used to find the shortest path in an unweighted graph?
A.
DFS
B.
BFS
C.
Dijkstra's Algorithm
D.
A* Search
Show solution
Solution
BFS can be used to find the shortest path in an unweighted graph because it explores all neighbors at the present depth prior to moving on to nodes at the next depth level.
Correct Answer:
B
— BFS
Learn More →
Q. Which traversal would you use to delete a binary tree?
A.
In-order
B.
Pre-order
C.
Post-order
D.
Level-order
Show solution
Solution
Post-order traversal is used to delete a binary tree as it deletes children before the parent.
Correct Answer:
C
— Post-order
Learn More →
Showing 61 to 66 of 66 (3 Pages)