Skip to content

Commit b0e06fc

Browse files
committed
Add import statement to algorithm codes
1 parent f03a5ab commit b0e06fc

File tree

77 files changed

+219
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+219
-67
lines changed

Backtracking/Knight's tour problem/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, Array2DTracer, LogTracer, Tracer } from 'algorithm-visualizer';
2+
13
/*
24
For N>3 the time taken by this algorithm is sufficiently high
35
Also it is not possible to visualise for N>6 due to stack overflow

Backtracking/N Queens Problem/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array2DTracer, LogTracer, Tracer } from 'algorithm-visualizer';
2+
13
const N = 4; // just change the value of N and the visuals will reflect the configuration!
24
const board = (function createArray(N) {
35
const result = [];

Cryptography/Affine Cipher/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, LogTracer, Randomize, Tracer } from 'algorithm-visualizer';
2+
13
function randString(length) {
24
const choices = 'abcdefghijklmnopqrstuvwxyz';
35
let text = '';

Cryptography/Caesar Cipher/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, LogTracer, Tracer } from 'algorithm-visualizer';
2+
13
const string = 'hello! how are you doing?';
24
const rotation = 5;
35
const alphabet = 'abcdefghijklmnopqrstuvwxyz';

Dynamic Programming/Catalan Number/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, LogTracer, Tracer } from 'algorithm-visualizer';
2+
13
const N = 10;
24
const A = new Array(N + 1);
35
for (let i = N; i >= 0; i--) {

Dynamic Programming/Fibonacci Sequence/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, Tracer } from 'algorithm-visualizer';
2+
13
const tracer = new Array1DTracer('Sequence');
24
const index = 15;
35
const D = [1, 1];

Dynamic Programming/Integer Partition/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array2DTracer, LogTracer, Randomize, Tracer } from 'algorithm-visualizer';
2+
13
const tracer = new Array2DTracer();
24
const logger = new LogTracer();
35
const integer = Randomize.integer(5, 14);

Dynamic Programming/Knapsack Problem/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, Array2DTracer, LogTracer, Tracer } from 'algorithm-visualizer';
2+
13
const val = [1, 4, 5, 7]; // The value of all available items
24
const wt = [1, 3, 4, 5]; // The weights of available items
35
const W = 7; // The maximum weight we can carry in our collection

Dynamic Programming/Longest Common Subsequence/code.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, Array2DTracer, LogTracer, Tracer } from 'algorithm-visualizer';
2+
13
const string1 = 'AGGTAB';
24
const string2 = 'GXTXAYB';
35
const m = string1.length;
@@ -20,7 +22,7 @@ for (i = 0; i <= m; i++) {
2022
for (j = 0; j <= n; j++) {
2123
if (i === 0 || j === 0) {
2224
A[i][j] = 0;
23-
} else if (string1[i - 1] == string2[j - 1]) {
25+
} else if (string1[i - 1] === string2[j - 1]) {
2426
tracer1.select(i - 1).wait();
2527
tracer2.select(j - 1).wait();
2628
tracer3.select(i - 1, j - 1).wait();
@@ -53,7 +55,7 @@ i = m;
5355
j = n;
5456
while (i >= 1 && j >= 1) {
5557
tracer3.select(i, j).wait();
56-
if (string1[i - 1] == string2[j - 1]) {
58+
if (string1[i - 1] === string2[j - 1]) {
5759
tracer1.select(i - 1).wait();
5860
tracer2.select(j - 1).wait();
5961

Dynamic Programming/Longest Increasing Subsequence/code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Array1DTracer, LogTracer, Randomize, Tracer } from 'algorithm-visualizer';
2+
13
const tracer = new Array1DTracer();
24
const logger = new LogTracer();
35
const A = Randomize.array1D(10, { min: 0, max: 10 });

0 commit comments

Comments
 (0)