Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
Sam is a tourist, One day he plans to go one country where there are N cities and each pair of city is connected to each other by a bidirectional road. Sam want to visit each city exactly once and he wants to start in one city and end in another city after traveling exactly N-1 roads. You have given a String[] path. If the j-th column of the i-th row of paths is '1', he must travel the road that connects city i and city j.


Suppose there are three cities(A,B,C), and Sam want to travel path between city A to city C. So there are 6 possible paths P(3,2)=6. For this example String[]path is {"001","000","100"} But only 4 paths allowed for Sam that are (B->A->C),(A->C->B),(B->C->A),(C->A->B) and paths( A->B->C) and (C->B->A) are not allowed because path A->C or C->A is not covered. So you have to find the possible paths where String[] path is given..
Posted
Comments
Reiss 14-Sep-11 5:41am    
This sounds like homework - we don't do your homework for you, it also appears that you haven't tried to do anything yourself - people are happy to help out with problems, not write your code for you
Legor 14-Sep-11 5:44am    
Nobody here will do your homework. But they're glad to help if u tell them where u can't succeed on your own. Use the "Improve Question" Button to edit your question.

1 solution

Is it 'the homework question of the week'?
Exactly the same question as already posted here. You may find my answer here[^].
 
Share this answer
 
v2
Comments
Legor 14-Sep-11 5:43am    
Probably the same class.
Emilio Garavaglia 14-Sep-11 7:55am    
yes: this one comes from the teacher! :-)
CPallini 14-Sep-11 7:59am    
The teacher: "Oh my God, this time I went too far! Even I am not able to solve such assignment, let's see if anyone at CodeProiject..."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900