A and Dijkstra Combined
A and Dijkstra Combined
Fig 6.1 shows an example map of places that the salesman visits.
The filled in circle represents the start and end point. The letters represent the places to visit. The lines are the
routes available and the numbers are the length of time each route takes to travel.
Explain how abstraction has been applied in the production of Fig 6.1
[2]
The programmer is using a tree to find the most efficient route. Fig 6.2 shows part of the tree with three levels
completed.
(i) The ‘Start’ nodes on level three are not expanded again as this is a repeat, ‘Start’ has already been
expanded.
Write the place names in the boxes in Fig 6.2, to complete the fourth level of the tree structure for the map
shown in Fig 6.1.
[3]
(ii) Explain why the tree in Fig 6.2 is not a binary tree.
[1]
[2]
(ii) The pseudocode below shows part of an algorithm which uses a queue to traverse the graph breadth-first.
Complete the missing elements of the algorithm.
[4]
[6]
State the full name of the data structure shown in Fig. 2.1.
[2]
(b) The structure in Fig. 2.1 is searched using the A* algorithm making use of the heuristic values.
(i) State what the heuristic values could represent in Fig. 2.1.
[1]
[1]
(iii) Perform an A* algorithm on the data structure in Fig. 2.1 to find the shortest distance between H and E.
Show each step of the process, and the calculations performed for each node visited.
(iv) Give one decision that is made in the A* algorithm, and describe the effect of this decision on the next step(s)
of the algorithm.
Decision _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Effect _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[3]
Fig. 3
Demonstrate how Dijkstra’s algorithm would find the shortest path to the solution in Fig. 3.
Compare the performance of Dijkstra’s algorithm and the A* search algorithm, making reference to heuristics, to
find the shortest path to the problem.
4 Some of the characters in a game will move and interact independently. Taylor is going to use graphs to plan the
movements that each character can take within the game.
DancerGold is one character. The graph shown in Fig. 1 shows the possible movements that DancerGold can
make.
Fig. 1
DancerGold’s starting state is represented by node A. DancerGold can take any of the paths to reach the end
state represented by node G.
The number on each path represents the number of seconds each movement takes.
The number in bold below each node is the heuristic value from A.
(ii) Perform an A* algorithm on the graph shown in Fig. 1 to find the shortest path from the starting node to the
end node. Show your working, the nodes visited and the distance. You may choose to use the table below to
give your answer.
Distance:
[8]
Fig. 5
[1]
(i) Show how Dijkstra’s algorithm can be used on the graph shown in Fig. 5 to find the shortest path from the
start node A and the end node H.
You should state the nodes on the final path and the overall distance. Show your working.
You may choose to use the table below to give your answer.
(ii) Give a similarity and difference between the performance of Dijkstra’s algorithm and the performance of A*
algorithm.
Similarity
Difference
[2]
ii 1 mark each 4
d Max 6. 6
1 mark for final solution, max 5 for showing
the stages
Total 18
Weighted/Undirected
Graph
e.g.
Effect:
Total 15
0 marks
No attempt to answer the question or
response is not worthy of credit.
Total 16
E ∞ 50 111 B 1 MARK
21+40=6
1
Total 10
Total 9