java - Depth First Search - Perform DFS on a tree
- by DJDonaL3000
Im trying to perform DFS on a Minimum Spanning Tree which contains 26 nodes.
Nodes are named 'A' to 'Z' and the tree is undirected.
I have an empty function called DFS here that I am trying to write, which (i presume) takes in the tree (a 2D array) a startNode (randomly selected node 'M') and the endNode (randomly selected node 'Z').
The weights of connected nodes are identified in the 2D array parameter, but how do I actually get started visiting nodes?
All that is required is to print each nodeName in the order of the DFS traversal.
Do I need to create a Node_class for each node in the 2d array??