Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/algo/AVL.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class AVL extends Algorithm {
4,
false,
);
this.insertField.setAttribute('data-shortcut-target', 'insert');
this.controls.push(this.insertField);

this.insertButton = addControlToAlgorithmBar('Button', 'Insert');
Expand All @@ -75,6 +76,7 @@ export default class AVL extends Algorithm {
4,
false,
);
this.deleteField.setAttribute('data-shortcut-target', 'delete');
this.controls.push(this.deleteField);

this.deleteButton = addControlToAlgorithmBar('Button', 'Delete');
Expand All @@ -91,6 +93,7 @@ export default class AVL extends Algorithm {
4,
false,
);
this.findField.setAttribute('data-shortcut-target', 'find');
this.controls.push(this.findField);

this.findButton = addControlToAlgorithmBar('Button', 'Find');
Expand Down Expand Up @@ -311,12 +314,12 @@ export default class AVL extends Algorithm {
act.setText,
0,
'Searching for ' +
value +
' : ' +
value +
' < ' +
tree.data +
' (look to left subtree)',
value +
' : ' +
value +
' < ' +
tree.data +
' (look to left subtree)',
);
this.cmd(act.step);
this.cmd(act.setHighlight, tree.graphicID, 0);
Expand All @@ -338,12 +341,12 @@ export default class AVL extends Algorithm {
act.setText,
0,
' Searching for ' +
value +
' : ' +
value +
' > ' +
tree.data +
' (look to right subtree)',
value +
' : ' +
value +
' > ' +
tree.data +
' (look to right subtree)',
);
this.cmd(act.step);
this.cmd(act.setHighlight, tree.graphicID, 0);
Expand Down Expand Up @@ -438,7 +441,7 @@ export default class AVL extends Algorithm {
this.resizeTree();
const connected = this.connectSmart(curr.graphicID, curr.left.graphicID);
connected && this.cmd(act.step);
// } else if (data > curr.data) {
// } else if (data > curr.data) {
} else if (this.compare(data, curr.data) > 0) {
this.cmd(act.setText, 0, `${data} > ${curr.data}. Looking at right subtree`);
this.cmd(act.step);
Expand Down Expand Up @@ -683,7 +686,7 @@ export default class AVL extends Algorithm {
this.connectSmart(curr.graphicID, curr.left.graphicID);
this.resizeTree();
}
// } else if (data > curr.data) {
// } else if (data > curr.data) {
} else if (this.compare(data, curr.data) > 0) {
this.cmd(act.setText, 0, `${data} > ${curr.data}. Looking right`);
this.cmd(act.step);
Expand Down
2 changes: 2 additions & 0 deletions src/algo/ArrayList.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class ArrayList extends Algorithm {
4,
false,
);
this.addValueField.setAttribute('data-shortcut-target', 'insert');
this.controls.push(this.addValueField);

addLabelToAlgorithmBar('at index', addTopHorizontalGroup);
Expand Down Expand Up @@ -143,6 +144,7 @@ export default class ArrayList extends Algorithm {
4,
true,
);
this.removeField.setAttribute('data-shortcut-target', 'delete');
this.controls.push(this.removeField);

// Remove from index button
Expand Down
31 changes: 17 additions & 14 deletions src/algo/BST.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default class BST extends Algorithm {
4,
false,
);
this.insertField.setAttribute('data-shortcut-target', 'insert');
this.controls.push(this.insertField);

this.insertButton = addControlToAlgorithmBar('Button', 'Insert');
Expand All @@ -91,6 +92,7 @@ export default class BST extends Algorithm {
4,
false,
);
this.deleteField.setAttribute('data-shortcut-target', 'delete');
this.controls.push(this.deleteField);

this.deleteButton = addControlToAlgorithmBar('Button', 'Delete');
Expand All @@ -107,6 +109,7 @@ export default class BST extends Algorithm {
4,
false,
);
this.findField.setAttribute('data-shortcut-target', 'find');
this.controls.push(this.findField);

this.findButton = addControlToAlgorithmBar('Button', 'Find');
Expand Down Expand Up @@ -603,12 +606,12 @@ export default class BST extends Algorithm {
act.setText,
0,
'Searching for ' +
value +
' : ' +
value +
' < ' +
tree.data +
' (look to left subtree)',
value +
' : ' +
value +
' < ' +
tree.data +
' (look to left subtree)',
);
this.cmd(act.step);

Expand All @@ -635,12 +638,12 @@ export default class BST extends Algorithm {
act.setText,
0,
' Searching for ' +
value +
' : ' +
value +
' > ' +
tree.data +
' (look to right subtree)',
value +
' : ' +
value +
' > ' +
tree.data +
' (look to right subtree)',
);
this.cmd(act.step);
this.cmd(act.setHighlight, tree.graphicID, 0, 'find');
Expand Down Expand Up @@ -765,7 +768,7 @@ export default class BST extends Algorithm {
this.resizeTree();
const connected = this.connectSmart(curr.graphicID, curr.left.graphicID);
connected && this.cmd(act.step);
// } else if (data > curr.data) {
// } else if (data > curr.data) {
} else if (this.compare(data, curr.data) > 0) {
this.highlight(10, 0, 'add');
this.highlight(11, 0, 'add');
Expand Down Expand Up @@ -865,7 +868,7 @@ export default class BST extends Algorithm {
this.connectSmart(curr.graphicID, curr.left.graphicID);
this.resizeTree();
}
// } else if (data > curr.data) {
// } else if (data > curr.data) {
} else if (this.compare(data, curr.data)) {
this.highlight(11, 0, this.predSuccMethod);
this.highlight(12, 0, this.predSuccMethod);
Expand Down
10 changes: 6 additions & 4 deletions src/algo/LinkedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default class LinkedList extends Algorithm {
4,
false,
);
this.addValueField.setAttribute('data-shortcut-target', 'insert');
this.controls.push(this.addValueField);

addLabelToAlgorithmBar('at index', addTopHorizontalGroup);
Expand Down Expand Up @@ -158,6 +159,7 @@ export default class LinkedList extends Algorithm {
4,
true,
);
this.removeField.setAttribute('data-shortcut-target', 'delete');
this.controls.push(this.removeField);

// Remove from index button
Expand Down Expand Up @@ -838,8 +840,8 @@ export default class LinkedList extends Algorithm {
runningRemoveIndexOnly
? this.highlight(12, 0, 'removeIndex')
: runningRemoveBack
? this.highlight(10, 0, 'removeBack')
: this.highlight(3, 0, 'removeFront');
? this.highlight(10, 0, 'removeBack')
: this.highlight(3, 0, 'removeFront');

this.cmd(act.step);
this.cmd(act.delete, this.linkedListElemID[index]);
Expand All @@ -863,8 +865,8 @@ export default class LinkedList extends Algorithm {
runningRemoveIndexOnly
? this.highlight(13, 0, 'removeIndex')
: runningRemoveBack
? this.highlight(11, 0, 'removeBack')
: this.highlight(4, 0, 'removeFront');
? this.highlight(11, 0, 'removeBack')
: this.highlight(4, 0, 'removeFront');
this.cmd(act.step);

return this.commands;
Expand Down
Loading