algorithms.tutorialhorizon.com
Depth-First Search (DFS) in 2D Matrix/2D-Array - Iterative Solution | Algorithms
Objective: Given a two-dimensional array or matrix, Do the depth-First Search (DFS) to print the elements of the given matrix. Implement Depth-first traversal in an iterative manner. Example: int [][] grid = new int[][] { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}} Output: Depth-First Traversal: 1 5 9 13 14 10 6 2 3 7 11 15 16 12 8 4