Skip to content

Commit 50ff257

Browse files
committed
use simpler tabulation function
1 parent f9ca27b commit 50ff257

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pages/tabulation_2dim_triangular.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ speed: 50
66

77
{{> tabulation_libs }}
88

9-
The solution for the subword pair $(i..j,k..l)$ is stored at $M[adr(i,j),adr(k,l)]$ where $M$ is a two-dimensional matrix of size $(|w|+1)\cdot(|w|+2) / 2$ in both dimensions, and $adr(i,j) = |w|\cdot i - (i\cdot(i-1)) \div 2 + j$. This partially eliminates the space loss of the [naive strategy](/tabulation_2dim_naive) -- while overlapping subwords still cause space loss (see the holes in the matrix).
9+
The solution for the subword pair $(i..j,k..l)$ is stored at $M[adr(i,j),adr(k,l)]$ where $M$ is a two-dimensional matrix of size $(|w|+1)\cdot(|w|+2) / 2$ in both dimensions, and $adr(i,j) = i + (j\cdot(j+1)) \div 2$. This partially eliminates the space loss of the [naive strategy](/tabulation_2dim_naive) -- while overlapping subwords still cause space loss (see the holes in the matrix).
1010

1111
**Hint**: Zoom out with your mouse scroll wheel for bigger word lengths!
1212

@@ -16,8 +16,7 @@ The solution for the subword pair $(i..j,k..l)$ is stored at $M[adr(i,j),adr(k,l
1616

1717
<script>
1818
Tabulation.prototype.adr = function(i,j) {
19-
//console.log(i + "," + j + " -> " + (this.len*i - Math.floor((i*(i-1)) / 2) + j));
20-
return this.len*i - Math.floor((i*(i-1)) / 2) + j;
19+
return i + Math.floor((j*(j+1)) / 2);
2120
}
2221

2322
Tabulation.prototype.solve = function(x1,x2,x3,x4,c) {
@@ -62,4 +61,4 @@ $(function() {
6261
tab.fill();
6362
window.tab = tab;
6463
});
65-
</script>
64+
</script>

0 commit comments

Comments
 (0)