FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Sorting time complexity by TornjV · Pull Request #30 · algorithm-visualizer/algorithm-visualizer · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
      • code.js
      • code.js
      • code.js
2 changes: 1 addition & 1 deletion algorithm/sorting/bubble/basic/code.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ do {
swapped = false;
tracer._select(N - 1);
for (var i = 1; i < N; i++) {
tracer._notify(i - 1, i);
if (D[i - 1] > D[i]) {
tracer._print('swap ' + D[i - 1] + ' and ' + D[i]);
var temp = D[i - 1];
D[i - 1] = D[i];
D[i] = temp;
swapped = true;
tracer._notify(i - 1, i);
}
}
tracer._deselect(N - 1);
Expand Down
2 changes: 1 addition & 1 deletion algorithm/sorting/quick/basic/code.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ function partition(low, high) {
var temp;

for (var j = low; j < high; j++) {
tracer._notify(i, j);
if (D[j] <= pivot) {
temp = D[i];
D[i] = D[j];
D[j] = temp;
tracer._notify(i, j);
i++;
}
}
Expand Down
8 changes: 3 additions & 5 deletions algorithm/sorting/selection/basic/code.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ for (var i = 0; i < D.length - 1; i++) {
var minJ = i;
tracer._select(i);
for (var j = i + 1; j < D.length; j++) {
if (D[j] < D[minJ]) {
tracer._select(j);
minJ = j;
tracer._deselect(j);
}
tracer._select(j);
if (D[j] < D[minJ]) minJ = j;
tracer._deselect(j);
}
if (minJ != i) {
tracer._print('swap ' + D[i] + ' and ' + D[minJ]);
Expand Down

Back | FazBrowse Home | New Git URL