[FEATURE] Add iterative DFS implementation for Graphs #111

Closed
opened 2026-01-29 15:03:45 +00:00 by claunia · 3 comments
Owner

Originally created by @ybrenning on GitHub (Jan 22, 2022).

Detailed description

The Graph-DFS implementation in dfs.c uses recursion, I would like to also add a function to dfs.c which performs an iterative DFS.

Context

I think it would make sense to also have a function in dfs.c with an iterative approach to depth-first search by using a simple stack data structure. I think it can make DFS easier to understand for some people and it's useful to demonstrate both iterative and recursive problem solving.

Possible implementation

Use a simple stack data structure to store unvisited vertices as opposed to using the call stack.

Additional information

No response

Originally created by @ybrenning on GitHub (Jan 22, 2022). ### Detailed description The Graph-DFS implementation in `dfs.c` uses recursion, I would like to also add a function to `dfs.c` which performs an iterative DFS. ### Context I think it would make sense to also have a function in `dfs.c` with an iterative approach to depth-first search by using a simple stack data structure. I think it can make DFS easier to understand for some people and it's useful to demonstrate both iterative and recursive problem solving. ### Possible implementation Use a simple stack data structure to store unvisited vertices as opposed to using the call stack. ### Additional information _No response_
claunia added the Staleenhancement labels 2026-01-29 15:03:45 +00:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 22, 2022):

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions[bot] commented on GitHub (Feb 22, 2022): This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 25, 2022):

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions[bot] commented on GitHub (Mar 25, 2022): This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Author
Owner

@github-actions[bot] commented on GitHub (Apr 1, 2022):

Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions!

@github-actions[bot] commented on GitHub (Apr 1, 2022): Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel or our [Discord server](https://discord.gg/c7MnfGFGa6). Thank you for your contributions!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#111