algorithms.tutorialhorizon.com
Breadth-First Search (BFS) in 2D Matrix/2D-Array | Algorithms
Objective: Given a two-dimensional array or matrix, Do the breadth-First Search (BFS) to print the elements of the given matrix. Implement a Breadth-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: Breadth-First Traversal: 1 2 5 3 6 9 4 7 10 13 8 11 14 12 15 16