a) Single file or single class? Are inner classes allowed? b) There are many ways to store a Graph, some of which are completely independent of object oriented programming (such as an adjacency...
Type: Posts; User: copeg
a) Single file or single class? Are inner classes allowed? b) There are many ways to store a Graph, some of which are completely independent of object oriented programming (such as an adjacency...
Think about how the current dfs method is working:
1 Gets the node and adds to stack:
2 finds the next unvisited neighbor
3 if you've reached the max count: end
4 else go to...
This is up to you. I don't know how much experience you have had with graphs or graph traversal. If none, then perhaps take a step back and learn them a bit in a more simple context. But at the same...
Yes! Together with a traversal/search algorithm (recursion seems the most obvious way to go about the search). My advice would be to write down in pseudo-code how you'd tackle this, first thinking...
That's good right? Always fun to learn something new! A tree would work of course, but another tiny hint if you don't mind it: a tree doesn't allow for circular paths which, if you consider each...
I suggest taking a step back and if you have not, draw the problem out on paper. If you want a tiny hint, scroll down to read the hint below. If not, don't keep reading (and let me know if you wish...
Did you decide on a data structure? An algorithm? What is it and why?
Break the problem down, as Norm said do some design work first. For example, think if there is any data structure you know of which looks similar to that of the picture (or could be used to store the...