Skip to content

Commit 9dec15e

Browse files
author
duaraghav8@gmail
committed
Merge remote-tracking branch 'upstream/gh-pages'
2 parents 4177731 + d7ae20f commit 9dec15e

File tree

18 files changed

+590
-525
lines changed

18 files changed

+590
-525
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ http://parkjs814.github.io/AlgorithmVisualizer
1111
### Contributing
1212
If you run _Algorithm Visualizer_ locally and files are not loaded because Cross-Origin Requests are blocked, use [http-server](https://github.com/indexzero/http-server) or [SimpleHTTPServer](https://docs.python.org/2/library/simplehttpserver.html) to resolve the issue. [(Issue #2)](https://github.com/parkjs814/AlgorithmVisualizer/issues/2)
1313

14-
If in need of any help check out or [**Wiki**](https://github.com/parkjs814/AlgorithmVisualizer/wiki) or join our [Gitter](https://gitter.im/parkjs814/AlgorithmVisualizer?utm_source=share-link&utm_medium=link&utm_campaign=share-link) chatroom!
14+
If in need of any help check out [**Wiki**](https://github.com/parkjs814/AlgorithmVisualizer/wiki) or join our [Gitter](https://gitter.im/parkjs814/AlgorithmVisualizer?utm_source=share-link&utm_medium=link&utm_campaign=share-link) chatroom!
1515
### Backers
1616

1717
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/algorithmvisualizer#backer)]

algorithm/category.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"insertion": "Insertion Sort",
3131
"selection": "Selection Sort",
3232
"bubble": "Bubble Sort",
33-
"quick": "Quicksort",
3433
"merge": "Merge Sort",
35-
"heap" : "Heapsort",
3634
"radix": "Radix Sort",
35+
"quick": "Quicksort",
36+
"heap" : "Heapsort",
3737
"shell": "Shellsort"
3838
}
3939
},
@@ -47,12 +47,13 @@
4747
"dp": {
4848
"name": "Dynamic Programming",
4949
"list": {
50-
"fibonacci": "Fibonacci sequence",
51-
"knapsack_problem": "Knapsack problem",
52-
"longest_increasing_subsequence": "Longest increasing subsequence",
53-
"max_subarray": "Maximum subarray",
54-
"max_sum_path": "Maximum sum path",
55-
"sliding_window": "Sliding window"
50+
"fibonacci": "Fibonacci Sequence",
51+
"knapsack_problem": "Knapsack Problem",
52+
"longest_increasing_subsequence": "Longest Increasing Subsequence",
53+
"max_subarray": "Maximum Subarray",
54+
"max_sum_path": "Maximum Sum Path",
55+
"sliding_window": "Sliding Window",
56+
"integer_partition": "Integer Partition"
5657
}
5758
},
5859
"etc": {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function partition(A, n, p){
2+
if (n === 0) tracer.logTracer._print('[' + A.join(', ') + ']');
3+
else {
4+
var end = n;
5+
if (p !== 0 && A[p-1] < n) end = A[p-1];
6+
for (var i = end; i > 0; i--){
7+
A[p] = i;
8+
partition(A, n-i, p+1);
9+
}
10+
}
11+
}
12+
13+
function integerPartition(n){
14+
//Calculate number of partitions for all numbers from 1 to n
15+
for (var i = 2; i <= n; i++){
16+
// We are allowed to use numbers from 2 to i
17+
for (var j = 1; j <= i; j++){
18+
// Number of partitions without j number + number of partitions with max j
19+
tracer._select(i, j)._wait();
20+
D[i][j] = D[i][j-1] + D[i-j][Math.max(j, i-j)];
21+
tracer._notify(i, j, D[i][j])._wait();
22+
tracer._denotify(i, j);
23+
tracer._deselect(i, j);
24+
}
25+
}
26+
return D[n][n];
27+
}
28+
29+
tracer.logTracer._print('Partitioning: ' + integer);
30+
partition(A, integer, 0);
31+
var part = integerPartition(integer);
32+
tracer.logTracer._print(part);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var tracer = new Array2DTracer().attach(new LogTracer());
2+
var integer = Math.floor(Math.random() * 10) + 5;
3+
var D = [], A = [];
4+
for (var i = 0; i <= integer; i++){
5+
D.push([]);
6+
D[0][i] = 1;
7+
D[i][1] = 1;
8+
for (var j = 0; j <= integer; j++) D[i][j]=0;
9+
}
10+
tracer._setData(D);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Integer Partition": "In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing n as a sum of positive integers.",
3+
"Complexity": {
4+
"time": "O(n(log n))",
5+
"space": "O(n<sup>2</sup>)"
6+
},
7+
"References": [
8+
"<a href='https://en.wikipedia.org/wiki/Partition_(number_theory)'>Wikipedia</a>"
9+
],
10+
"files": {
11+
"basic": "Integer partition"
12+
}
13+
}

algorithm/dp/knapsack_problem/desc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Knapsack Problem": "Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.",
33
"Complexity": {
4-
"time": "O(n<sup>2</sup>",
4+
"time": "O(n<sup>2</sup>)",
55
"space": "O(n<sup>2</sup>)"
66
},
77
"References": [

algorithm/string/knuth_morris_pratt/substring_search/code.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ Number.prototype.mod = function (n) {
33
return ((this%n)+n)%n;
44
};
55

6-
function randString (length) {
7-
var result = Math.random ().toString (36);
8-
return result.substring (result.length - length);
9-
}
10-
116
function tracker (substring) {
127
var i = 1, j = 0;
138

@@ -110,4 +105,4 @@ var positions = kmp (string, substring);
110105
logger._print ('Substring positions are: ' + (positions.length ? String (positions) : 'NONE'));
111106
for (var i = 0; i < positions.length; i++) {
112107
stringTracer._select (positions [i], positions [i] + substring.length - 1)._wait ();
113-
}
108+
}

branding/anim.gif

1.09 MB
Loading

branding/logo.png

50.5 KB
Loading

branding/logo.psd

381 KB
Binary file not shown.

0 commit comments

Comments
 (0)