Skip to content

Commit 3ce85c4

Browse files
committed
add dp
1 parent 75751ab commit 3ce85c4

File tree

12 files changed

+48
-4
lines changed

12 files changed

+48
-4
lines changed

algorithm/category.json

+6
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@
1414
"bubble": "Bubble Sort",
1515
"quick": "Quicksort"
1616
}
17+
},
18+
"etc": {
19+
"name": "Uncategorized",
20+
"list": {
21+
"dp": "Dynamic Programming"
22+
}
1723
}
1824
}

algorithm/etc/dp/config.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"def": "Dynamic programming is both a mathematical optimization method and a computer programming method. In both contexts it refers to simplifying a complicated problem by breaking it down into simpler sub-problems in a recursive manner.",
3+
"apps": [],
4+
"cpx": {
5+
"time": "varies",
6+
"space": "varies"
7+
},
8+
"refs": [
9+
"https://en.wikipedia.org/wiki/Dynamic_programming"
10+
],
11+
"files": {
12+
"fibonacci": "Fibonacci Sequence"
13+
}
14+
}

algorithm/etc/dp/fibonacci/code.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
for (var i = 2; i < index; i++) {
2+
D[i] = D[i - 2] + D[i - 1];
3+
tracer._selectSet([i - 2, i - 1]);
4+
tracer._notify(i);
5+
tracer._deselectSet([i - 2, i - 1]);
6+
}

algorithm/etc/dp/fibonacci/data.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var tracer = new Array1DTracer();
2+
var index = 15;
3+
var D = [1, 1];
4+
for (var i = 2; i < index; i++) {
5+
D.push(0);
6+
}
7+
tracer.setData(D);

algorithm/graph_search/bfs/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"https://en.wikipedia.org/wiki/Breadth-first_search"
1818
],
1919
"files": {
20-
"basic": "Searching a tree",
20+
"tree": "Searching a tree",
2121
"shortest_path": "Finding the shortest path"
2222
}
2323
}

algorithm/graph_search/dfs/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"https://en.wikipedia.org/wiki/Depth-first_search"
2222
],
2323
"files": {
24-
"basic": "Searching a tree",
24+
"tree": "Searching a tree",
2525
"all_paths": "Going through all possible paths without making any circuit",
2626
"weighted_graph": "DFS of Weighted Graph",
2727
"shortest_path": "Finding the shortest path"

css/stylesheet.css

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ section {
136136
bottom: 50%;
137137
left: 0;
138138
right: 0;
139+
overflow: scroll;
139140
}
140141

141142
.tab_container {

js/module/array2d.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,18 @@ Array2DTracer.prototype.refresh = function () {
163163
Tracer.prototype.refresh.call(this);
164164

165165
var $parent = $table.parent();
166-
$table.css('margin-top', $parent.height() / 2 - $table.height() / 2);
167-
$table.css('margin-left', $parent.width() / 2 - $table.width() / 2);
166+
var top = $parent.height() / 2 - $table.height() / 2;
167+
var left = $parent.width() / 2 - $table.width() / 2;
168+
if (top < 0) {
169+
$table.css('margin-top', 0);
170+
$parent.scrollTop(-top);
171+
}
172+
else $table.css('margin-top', top);
173+
if (left < 0) {
174+
$table.css('margin-left', 0);
175+
$parent.scrollLeft(-left);
176+
}
177+
else $table.css('margin-left', left);
168178
};
169179

170180
// Override

0 commit comments

Comments
 (0)