Skip to content

Commit

Permalink
Merge pull request #5 from Asmi1108/Minor-changes-in-the-file-Depth_f…
Browse files Browse the repository at this point in the history
…irst_search.md

Update Depth_first_search.md
  • Loading branch information
Asmi1108 authored Nov 8, 2024
2 parents 3ede5b2 + d3fc22a commit 834a307
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions java/Depth_first_search.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
id: DFS
id: depth-first-search
sidebar_position: 3
title: Depth-First Search
sidebar_label: DFS
description: DFS algorithm implementation in Java.
tags: [java, searching, graph traversal]
---

##*Description*
## *Description*

Depth-First Search (DFS) is a graph traversal algorithm that explores nodes in a depthward motion. It starts at a selected node (root) and explores as far as possible along each branch before backtracking.

##*Java implementation*
## *Java implementation*

```
public class DFS {
Expand All @@ -38,18 +38,18 @@ public class DFS {
}
```

#*Complexity*
# *Complexity*

- Time Complexity: O(V + E), where V is vertices and E is edges.
- Space Complexity: O(V), for visited array and recursive stack.

#*Use Cases for example*
# *Use Cases for example*

- Traversing social networks.
- Web crawlers.
- Finding connected components.

#*Variants of this algorithm include:*
# *Variants of this algorithm include:*

- Pre-order DFS (current node before neighbors).
- Post-order DFS (current node after neighbors).
Expand Down

0 comments on commit 834a307

Please sign in to comment.