Skip to content

Commit d2c6d14

Browse files
committed
Add Hamiltonian cycle.
1 parent 569c6ae commit d2c6d14

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/algorithms/graph/hamiltonian-cycle/hamiltonianCycle.js

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function hamiltonianCycleRecursive({
9191
cycle: currentCycle,
9292
});
9393

94+
// BACKTRACKING.
9495
// Remove candidate vertex from cycle path in order to try another one.
9596
currentCycle.pop();
9697
}

src/algorithms/uncategorized/n-queens/nQueens.js

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function nQueensRecursive(solutions, previousQueensPositions, queensCount, rowIn
7272
// Try to place all other queens as well.
7373
nQueensRecursive(solutions, queensPositions, queensCount, rowIndex + 1);
7474

75+
// BACKTRACKING.
7576
// Remove the queen from the row to avoid isSafe() returning false.
7677
queensPositions[rowIndex] = null;
7778
}

0 commit comments

Comments
 (0)