Algorithms and Data Structures · Junior · Question 69 of 75

What is a matrix (2D grid) usually represented as in JavaScript?

Explanation

Grids show up in many problems: maps, game boards, images. Each cell often has up to four neighbors (r±1, c) and (r, c±1), so a grid is also a graph that can be traversed with BFS or DFS.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 69

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz