Question: int find _ path ( const char stage [ ] [ MAX _ NUM _ FLOOR ] [ MAX _ ENCOUNTER _ LENGTH ] ,
int findpathconst char stageMAXNUMFLOORMAXENCOUNTERLENGTH int numtower, int currenttower,
int numfloor, int exploredfloorcount, int exploredfloor
int strength, int floorpath int stagepathMAXNUMFLOOR
TODO Base case : If the current tower is out of bounds, return the strength
if currenttower numtower
return strength;
End of TODO
TODO Base case : If all floors have been explored, write the explored floor to floor path backtracking then return the strength
if exploredfloorcount numfloor
copyfloor floorpath,exploredfloor;
return strength;
End of TODO
Recursive case
int higheststrength ;
int bestfloorpathMAXNUMFLOOR;
Try every unexplored floor in the current tower.
for int i; i higheststrength
higheststrength recursionresult;
copyfloorbestfloorpath, recursionfloorpath;
If the current tower is fully explored, backtrack the best path for the current floor and call the recursive function for the next tower
if exploredfloorcount
TODO: Backtrack the best path for the current tower using a line of code Use copyfloor
copyfloorstagepathcurrenttowerbestfloorpath; copy the current explored result to best path array
End of TODO
int floorexploredMAXNUMFLOOR;
int floorpathMAXNUMFLOOR;
TODO: Complete the recursive function call to move to the next tower
findpathstagenumtower,currenttower numfloor, floorexplored,strength,floorpath,stagepath; current tower to next tower, explored floor count change to in new tower
End of TODO
TODO: Backtrack the best path for the current floor selection using a line of code Use copyfloor
copyfloorfloorpath,bestfloorpath;
End of TODO
return higheststrength;
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
