Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

A* algorithm

An improved version of Dijkstra’s algorithm. A finds the shortest path from a starting point to a goal on a graph. A combines actual travel costs and estimated costs to prioritize promising paths.

Step-by-Step Overview

Step-by-Step Overview

  • Steps include:
    • 1 Initialization
    • 2 Cost Calculation
    • 3 Explore
    • 4 Expand Neighbors
    • 5 Close Node
    • 6 Repeat
    • 7 Reconstruct Path
Initialization

Initialization

  • Step 1 Initialization
    • Start with an open list (to explore) and a closed list (evaluated).
    • Add the starting point to the open list with an initial cost of 0.
Cost calculation

Cost calculation

  • Step 2: Cost Calculation
  • For each node, calculate:
    • g(n): Cost from the start to the node.
    • h(n): Estimated cost from the node to the goal.
    • Total cost: f(n) = g(n) + h(n).
Explore

Explore

  • Step 3: Explore
    • While the open list isn’t empty:
    • Select the node with the lowest f(n) (current node).
    • If it’s the goal, reconstruct the path and finish.
Expand neighbors

Expand neighbors

  • Step 4: Expand Neighbors
    • For each neighbor of the current node:
    • Calculate new g(n). If it’s lower than before, update costs and set the current node as the neighbor’s parent.
    • Add the neighbor to the open list if not already present.
Close node, repeat, reconstruct path

Close node, repeat, reconstruct path

  • Step 5: Close Node
    • Move the current node to the closed list.
  • Step 6: Repeat
    • Go back to step 3 until the goal is found or no paths remain.
  • Step 7: Reconstruct Path
    • If the goal is reached, trace back from the goal to the start using parent pointers to get the path.
Jump to other topics
1

Components of a Computer

2

Software & Software Development

3

Exchanging Data

4

Data Types, Data Structures & Algorithms

5

Legal, Moral, Cultural & Ethical Issues

6

Elements of Computational Thinking

6.1

Thinking Abstractly

6.2

Thinking Ahead

6.3

Thinking Procedurally

6.4

Thinking Logically

6.5

Thinking Concurrently

7

Problem Solving & Programming

8

Algorithms

Practice questions on A* Algorithm

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
Answer all questions on A* Algorithm

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium