Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Need help figuring an algorithm to this. Hardest algorithm?

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, I have a problem and needs to determine an algorithm using java. The problem is this image:


Santa Claus needs to go to all of the places marked in red. He starts in the topmost level (Santa Claus Village)
And he needs to go to places marked in circles chronologically (or not chronologically) from left to right.
For example, to go to California, he must go to North America then to Us then to California.
After going to california, he must go to LA by going back to US then travel to Texas then LA.
He must go to Virginia by going back to Texas to US then Virginia
Then he must go to Hidalgo by going back to US then North America >Mexico>Hidalgo
Then go to Germany by back to Mexico> North America > Santa Claus Village > Europe > Germany and so on...


The hardest part is that there is no finite number of loop inside NA, Europe and Asia
Please advice me people. I'm having hard time solving this problem. Please please please
 
author
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matt Taylor wrote:
The hardest part is that there is no finite number of loop inside NA, Europe and Asia
Please advice me people. I'm having hard time solving this problem. Please please please



Looks like it can be solved by a standard depth first search algorithm -- which of course, is one of the earlier algorithms taught under the banner of recursion. Perhaps you should look into "recursion" techniques?

Henry
 
Bartender
Posts: 1197
22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course we're not going to do your homework for you. However, if you're stuck at any particular point we're more than happy to help. DoYourOwnHomework
 
Look ma! I'm selling my stuff!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic