All Path Finding 23
All Path Finding 23
The game’s ‘challenging’ level has intelligent enemies that hunt down the character in an attempt to stop the
user from winning. The program plans the enemies’ moves in advance to identify the most efficient way to stop
the user from winning the game.
The possible moves are shown in a graph. Each node represents a different state in the game. The lines
represent the number of moves it will take to get to that state.
Show how Dijkstra’s algorithm would find the shortest path from A to H.
2(a) A puzzle has multiple ways of reaching the end solution. Fig. 3 shows a graph that represents all possible routes
to the solution. The starting point of the game is represented by A, the solution is represented by J. The other
points in the graph are possible intermediary stages.
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.
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]
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.
[2]
(ii) Perform an A* algorithm on the graph shown in Fig. 1 to find the shortest path from the starting node to the
Distance:
[8]
Fig. 4.1
[1]
(i) Explain the difference between a depth-first (post-order) and breadth-first traversal.
[4]
(ii) Show how a depth-first (post-order) traversal would find the path between node A and node X for the
structure shown in Fig. 4.1.
(iii) Explain how you used backtracking in your answer to part (b)(ii).
[3]
Explain how concurrent processing could be used in searching algorithms, and evaluate the benefits and trade-
offs from implementing concurrent processing in a searching algorithm.
[9]
State the full name of the data structure shown in Fig. 2.1.
[2]
(c) 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]
1 1 mark for final solution, max 5 for showing 6 Guidance – 1 mark only for stating the
the stages solution of A-C-D-E-G-H length 10
AO1.2
(1) Examiner’s Comments
• Mark A as the current node initially AO2.2
• Record B = 1, C = 2 (mark A as visited) (3) Exemplar 2
• Record E = 5 (and mark B as visited) AO2.2
• (Record D = 3, F = 5 (and mark B as (2)
visited)
• Change E to 4 (overriding previous
value, and mark D as visited)
• Record G = 6 (and mark E as visited)
• …Do not change G as greater than
current (mark F as visited)
• (G as visited) H = 10 (Mark G as
visited)
• Solution: A-C-D-E-G-H path length 10
Total 6
0 marks
No attempt to answer the question or
response is not worthy of credit.
Total 16
ii 1 mark each 4
d Max 6. 6
1 mark for final solution, max 5 for showing
the stages
Total 18
E ∞ 50 111 B 1 MARK
21+40=6
1
Total 10
Examiner’s Comment:
A number of candidates incorrectly
identified the data structure as a binary
tree which indicated that this was the only
type of tree that they were familiar with.
Descriptions of depth and breadth first
traversals were often very vague, and
precision in terms of the algorithmic steps
involved would have produced stronger
answers. A pleasing number of candidates
produced the correct traversal of the tree,
but of those, a number did not appreciate
that the node was only output when it was
popped from the stack, and hence missed
location G before X was actually output.
Total 14
6 a Mark Band 3 – High level (7-9 marks) 9 AO1: knowledge and understanding
The candidate demonstrates a thorough Indicative content
knowledge and understanding of
concurrent processing; the material is
generally accurate and detailed. Carrying out more than one task at a
The candidate is able to apply their time
knowledge and understanding directly and Multiple processors
consistently to the context provided Each processor performs
(searching algorithms). simultaneously
Evidence/examples will be explicitly Each processor performs tasks
relevant to the explanation. independently
The candidate provides a thorough
discussion which is well balanced. and/or
Evaluative comments are consistenly
relevant and well considered.
A program has multiple threads
There is a well-developed line of reasoning Each thread starts and ends at
which is clear and logically structured. The different times
information presented is relevant and Each thread overlaps
substantiated. Each thread runs independently
The candidates makes a limited attempt to May waste time investigating inefficient
apply acquired knowledge and solutions
understanding to the context provided More difficult to program especially to
(searching algorithms). cooperate
The candidate provides a limited More memory intensive
discussion which is narrow in focus. Linear search scales very with
Judgements if made are weak and additional processors
unsubstantiated. Binary search can perform better on
The information is basic and comunicated large data sets with one processor than
in an unstructured way. The information is linear search with many processors
supported by limited evidence and the
relationship to the evidence may not be
clear.
0 marks
No attempt to answer the question or
response is not worthy of credit.
Weighted/Undirected
Graph
e.g.
Effect:
Total 24