I am an amateur programmer who is learning to program. I have never had courses in computer science, so I had difficulties with this trivial problem:
class Room { String name; ArrayList<Room> neighbors = new ArrayList<Room>();
Each room has several neighbors. More than 4, so this does not look like a matrix-oriented problem. You are given the final room, and you must find the shortest path from the start room (comparing the names of the rooms). The result should be a “way” as follows:
Start: Kitchen
End: Toilet
Way: Kitchen, Living room, Hallway, Bedroom, Toilet.
I think I should use some recursion for the rooms, and I think I should save, where I was already in some kind of stack. But I do not know how to start.
Can some of you guys help me? Thanks
Nancy source share