Question: Exercise 1 ( 1 0 points ) . Consider the A * algorithm using a perfect heuristic function h , i . e . ,
Exercise points Consider the A algorithm using a perfect heuristic function h ie for any node state n hn equals the minimal cost from n to a goal state. Modify the pseudocode for Afig so it improves in space andor time complexity as much as possible. The better the solution the higher the grade. Explain your answer.
PLEASE WRITE THE ANSWER IN THIS PSEUDOCODE FORMAT
Pseudocode:
function BESTFIRSTSEARCHproblemfreturns a solution node or failure nodeNODESTATEproblem.INITIAL
frontiera priority queue ordered by f with node as an element
reacheda lookup table, with one entry with key problem.INITIAL and value node
while not ISEMPTYfrontierdo
nodePOPfrontier
if problem.ISGOALnodeSTATEthen return node
for each child in EXPANDproblemnodedo
schildSTATE
if s is not in reached or child.PATHCOST reachedsPATH COST then
reachedschild add
child to frontier
return failure
function EXPANDproblemnodeyields nodes
snodeSTATE
for each action in problem.ACTIONSsdo
s problemRESULTsaction
costnodePATHCOST problemACTIONCOSTsactions
yield NODESTATEs PARENTnode, ACTIONaction, PATH COSTcost
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
