logo

Crowdly

Browser

Add to Chrome

We have a simplified road map of Romania. Length of each road segment is shown. ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

We have a simplified road map of Romania. Length of each road segment is shown.

rumeenia kaart

Problem: find the path from S (Sibiu) to B (Bucharest).

We will use A* search. We need a heuristic function, for that we can use the distance of each point from the goal Bucharest:

rumeenia teepikkused

Simulate the steps of the A* search with pen and paper (or a spreadsheet). The following table will help:

ng(n)h(n)f(n)
S0253253

Mark down the current node in search tree (n) and the matching path length so far g(n) and heuristic value h(n). In the initial state, Sibiu, the path so far has length 0. h(n) can be taken directly from the table of distances. f(n) = g(n) + h(n).

Then follow the algorithm:

  1. select the row from the table with lowest f(n) that you haven't used yet. Mark it as "used".
  2. If on this row the last city is "B" then the row contains the solution and its path length.
  3. if it's not, find the cities you can move to from the last city. Add a row for each of these neighbor nodes to the table

Table after adding the neighbors of the initial state:

ng(n)h(n)f(n)
S0253253
SF99176275
SR80193273
SO151380531
SA140366506
Why does the node column contain SF, SR, etc?

Each row is a node in the search tree. To represent the node properly we write down the city and the path leading to it. Sibiu-Oradea-Zerind and Sibiu-Arad-Zerind are different paths, so we cannot use just "Z" to represent them.

Keep building the table. What is the solution of A* (enter in this format: ABCD)?

More questions like this

Want instant access to all verified answers on moodle.taltech.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome