Created
June 3, 2020 09:08
-
-
Save bhaveshmunot1/4e6f965b5e2f2f4436e7b08e2b19e613 to your computer and use it in GitHub Desktop.
Print Depth First Traversal using recursion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void print_depth_first_traversal(GraphNode *node) { | |
if (is_visited(node)) { | |
return; | |
} | |
mark_visited(node); | |
for (GraphNode *neighbor : node->neighbors) { | |
print_depth_first_traversal(neighbor); | |
} | |
print(node->value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment