A Java depth-first search (DFS) project that checks whether a valid path exists from Start (S) to End (E) in a 2D grid.
- Reads a grid from console input.
- Treats:
- S as start
- E as end
- 0 as walkable cell
- 1 as blocked cell (wall)
- Runs DFS in 4 directions (up, down, left, right).
- Prints:
- Path Exists
- No Path Exists
- Main.java: Handles user input and runs the validator.
- PathValidator.java: Contains DFS path-check logic.
- index.html: Optional browser helper to generate/edit a grid and copy values for Java testing.
- Java 8 or newer
From this project folder, run:
javac Main.java PathValidator.java
java Main- Enter number of rows.
- Enter number of columns.
- Enter each row as a string of characters with no spaces.
Example for a 3x3 grid:
Rows: 3
Columns: 3
Row 0: S01
Row 1: 001
Row 2: 00E
In this example, output should be:
Path Exists
Open index.html in a browser to:
- Generate a random grid
- Edit cells (S, E, 0, 1)
- View grid values to use as test input in Java
This page is a helper UI and does not run the Java code directly.
- Ensure the grid has at least one S and one E.
- If there are multiple S or E cells, behavior is based on the first S found and any E reachable from it.