Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2c6d14

Browse files
committed
Add Hamiltonian cycle.
1 parent569c6ae commitd2c6d14

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)

[8]ページ先頭

©2009-2025 Movatter.jp