AlgoGenesis / C

AlgoGenesis is a centralized open-source platform dedicated to providing optimized and well-documented algorithm implementations in C. Perfect for both beginners and advanced users, this repository serves as a comprehensive learning resource for solving algorithmic challenges.
MIT License
70 stars 219 forks source link

[NEW ALGORITHM ]Depth-First Search (DFS) in graph algorithm Folder #546

Closed pragna7 closed 5 days ago

pragna7 commented 1 week ago

Name:
[NEW ALGORITHM ]Depth-First Search (DFS)

About:
Depth-First Search (DFS) is a graph traversal algorithm that explores as far as possible along each branch before backtracking. This method is particularly useful for searching tree or graph data structures and can be implemented using either recursion or an explicit stack. Here’s a detailed overview of how DFS works and its key features:

Key Features of DFS: Starting Point: DFS begins at a selected node (often referred to as the root in trees) and explores as deep as possible along each branch before moving on to the next branch.

Data Structure: DFS can be implemented using a stack (either explicitly with a data structure or implicitly through recursion).

Backtracking: DFS employs backtracking, which means that when it reaches a node with no unvisited neighbors, it backtracks to the last visited node that has unexplored neighbors and continues the search from there.

Space Complexity: The space complexity of DFS can be 𝑂(𝑉)O(V) in the worst case, where 𝑉V is the number of vertices, primarily due to the stack space used for recursion.

Time Complexity: The time complexity of DFS is 𝑂(𝑉+𝐸)O(V+E), where 𝑉V is the number of vertices and 𝐸E is the number of edges in the graph. DFS is not guaranteed to find the shortest path in unweighted graphs, but it will find a solution if one exists. Labels:
new algorithm, gssoc-ext, hacktoberfest, level1

Assignees:

github-actions[bot] commented 1 week ago

πŸ‘‹ Thank you for raising an issue! We appreciate your effort in helping us improve. Our team will review it shortly. Stay tuned!