QuizzesIntroduction to Dijkstra and A* Algorithms
beginner
dsa

Introduction to Dijkstra and A* Algorithms

A beginner's quiz on understanding the basics of Dijkstra and A* graph algorithms.

15 minutes 15 questions Pass at 70%
Time Limit
15 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

15 questions on Introduction to Dijkstra and A* Algorithms. Work through them here, then start the quiz to answer them and see your score.

  1. 1.What is the primary purpose of Dijkstra's algorithm?

    • ATo perform depth-first search on a graph
    • BTo find the minimum spanning tree of a graph
    • CTo find the shortest path between two nodes in a graph
    • DTo sort elements in an array
  2. 2.Which data structure is commonly used in Dijkstra's algorithm to select the next node with the smallest tentative distance?

    • AStack
    • BPriority Queue
    • CLinked List
    • DQueue
  3. 3.In Dijkstra's algorithm, what is the initial distance assigned to the starting node?

    • AOne
    • BNegative Infinity
    • CZero
    • DInfinity
  4. 4.What is a key difference between Dijkstra's algorithm and A* algorithm?

    • ADijkstra's algorithm is faster
    • BA* can only be used on trees
    • CA* uses a heuristic to guide its search
    • DDijkstra's algorithm requires a heuristic
  5. 5.Which of the following is a common heuristic used in the A* algorithm?

    • ABubble sort
    • BBinary search
    • CEuclidean distance
    • DBreadth-first search
  6. 6.What is the time complexity of Dijkstra's algorithm using a priority queue?

    • AO(E log V)
    • BO(V + E log V)
    • CO(V log E)
    • DO(V^2)
  7. 7.In A* algorithm, what does the function f(n) represent?

    • AThe total estimated cost of the cheapest solution through node n
    • BThe number of nodes visited
    • CThe cost from n to the goal
    • DThe cost from the start node to n
  8. 8.Which algorithm guarantees finding the shortest path if the heuristic is admissible?

    • ADijkstra's
    • BBoth A* and Dijkstra's
    • CA*
    • DNeither
  9. 9.What is the role of the heuristic function in the A* algorithm?

    • ATo estimate the cost from the current node to the goal
    • BTo determine the shortest path
    • CTo sort the nodes in the graph
    • DTo calculate the exact cost to the goal
  10. 10.Which of the following is a limitation of Dijkstra's algorithm?

    • AIt cannot handle negative edge weights
    • BIt is not guaranteed to find the shortest path
    • CIt only works on trees
    • DIt requires a heuristic
  11. 11.What does the g(n) function represent in the A* algorithm?

    • AThe cost from the start node to n
    • BThe total estimated cost of the cheapest solution through n
    • CThe estimated cost from n to the goal
    • DThe number of nodes expanded
  12. 12.Which algorithm is more suitable for finding the shortest path in a graph with non-negative weights?

    • AA* algorithm
    • BNeither
    • CDijkstra's algorithm
    • DBoth are equally suitable
  13. 13.What is the main advantage of using A* over Dijkstra's algorithm?

    • AA* is simpler to implement
    • BA* requires less memory
    • CA* guarantees optimality
    • DA* can be faster due to its heuristic
  14. 14.In Dijkstra's algorithm, what happens if a shorter path to a node is found?

    • AUpdate the node's distance and predecessor
    • BIgnore the new path
    • CRemove the node from the graph
    • DRestart the algorithm
  15. 15.What is a common application of the A* algorithm?

    • AEncrypting data
    • BSorting numbers
    • CCompiling code
    • DPathfinding in games