Skip to content

Commit 3c1f557

Browse files
authored
Fix Markdown formatting in matrices.md
1 parent 9ba91d9 commit 3c1f557

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

notes/matrices.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Matrices represent images, game boards, and maps. Many classic problems reduce t
44

55
### Conventions
66

7-
**Rows indexed \$0..R-1\$, columns \$0..C-1\$; cell \$(r,c)\$.**
7+
**Rows indexed $0..R-1$, columns $0..C-1$; cell $(r,c)$.**
88

9-
Rows increase **down**, columns increase **right**. Think “top-left is \$(0,0)\$”, not a Cartesian origin.
9+
Rows increase **down**, columns increase **right**. Think “top-left is $(0,0)$”, not a Cartesian origin.
1010

11-
Visual index map (example \$R=6\$, \$C=8\$; each cell labeled \$rc\$):
11+
Visual index map (example $R=6$, $C=8$; each cell labeled $rc$):
1212

1313
```
1414
c → 0 1 2 3 4 5 6 7
@@ -29,11 +29,11 @@ r ↓ +----+----+----+----+----+----+----+----+
2929

3030
Handy conversions (for linearization / array-of-arrays):
3131

32-
* Linear index: \$\text{id}=r\cdot C+c\$.
33-
* From id: \$r=\lfloor \text{id}/C \rfloor\$, \$c=\text{id}\bmod C\$.
34-
* Row-major scan order (common in problems): for \$r\$ in \$0..R-1\$, for \$c\$ in \$0..C-1\$.
32+
* Linear index: $\text{id}=r\cdot C+c$.
33+
* From id: $r=\lfloor \text{id}/C \rfloor$, $c=\text{id}\bmod C$.
34+
* Row-major scan order (common in problems): for $r$ in $0..R-1$, for $c$ in $0..C-1$.
3535

36-
**Row-major vs column-major arrows (same \$3\times 6\$ grid):**
36+
**Row-major vs column-major arrows (same $3\times 6$ grid):**
3737

3838
```
3939
Row-major (r, then c): Column-major (c, then r):
@@ -44,9 +44,9 @@ Row-major (r, then c): Column-major (c, then r):
4444
→ → → → → → ↓ ↓ ↓
4545
```
4646

47-
**Neighborhoods: \$\mathbf{4}\$-dir \$\Delta={(-1,0),(1,0),(0,-1),(0,1)}\$; \$\mathbf{8}\$-dir adds diagonals.**
47+
**Neighborhoods: $\mathbf{4}$-dir $\Delta={(-1,0),(1,0),(0,-1),(0,1)}$; $\mathbf{8}$-dir adds diagonals.**
4848

49-
The offsets \$(\Delta r,\Delta c)\$ are applied as \$(r+\Delta r,\ c+\Delta c)\$.
49+
The offsets $(\Delta r,\Delta c)$ are applied as $(r+\Delta r,\ c+\Delta c)$.
5050

5151
**4-neighborhood (“+”):**
5252

@@ -345,7 +345,7 @@ $$
345345
$$
346346

347347
$$
348-
\text{Output sequence: } 1,\,2,\,3,\,4,\,8,\,12,\,11,\,10,\,9,\,5,\,6,\,7
348+
\text{Output sequence: } 1,2,3,4,8,12,11,10,9,5,6,7
349349
$$
350350

351351
**How it works**
@@ -369,7 +369,7 @@ a & b & c \\
369369
d & e & f
370370
\end{bmatrix}
371371
\quad\Rightarrow\quad
372-
\text{One order: } a,\, b,\, d,\, e,\, c,\, f
372+
\text{One order: } a, b, d, e, c, f
373373
$$
374374

375375
* Time: $O(R\cdot C)$; Space: $O(1)$.
@@ -403,13 +403,13 @@ BFS layers (distance mod 10):
403403
Legend: walls (#), goal reached (X)
404404
```
405405

406-
BFS explores in **expanding “rings”**; with 4-dir edges, each step increases Manhattan distance by 1 (unless blocked). Time \$O(RC)\$, space \$O(RC)\$ with a visited matrix/queue.
406+
BFS explores in **expanding “rings”**; with 4-dir edges, each step increases Manhattan distance by 1 (unless blocked). Time $O(RC)$, space $O(RC)$ with a visited matrix/queue.
407407

408408
**Obstacles / costs / diagonals.**
409409

410-
* Obstacles: skip neighbors that are `#` (or where cost is \$\infty\$).
410+
* Obstacles: skip neighbors that are `#` (or where cost is $\infty$).
411411
* Weighted grids: Dijkstra / 0-1 BFS on the same neighbor structure.
412-
* 8-dir with Euclidean costs: use \$1\$ for orthogonal moves and \$\sqrt{2}\$ for diagonals (A\* often pairs well here with an admissible heuristic).
412+
* 8-dir with Euclidean costs: use $1$ for orthogonal moves and $\sqrt{2}$ for diagonals (A\* often pairs well here with an admissible heuristic).
413413

414414
**Common symbols:**
415415

@@ -428,7 +428,7 @@ Find the minimum steps from S to T.
428428
*Example*
429429

430430
$$
431-
\text{Grid (0 = open, 1 = wall), } S = (0,0),\; T = (2,3)
431+
\text{Grid (0 = open, 1 = wall), } S = (0,0), T = (2,3)
432432
$$
433433

434434
$$

0 commit comments

Comments
 (0)