Skip to content

Commit 57521c3

Browse files
authored
Add files via upload
1 parent 1df43db commit 57521c3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Algorithm-Visualiser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,15 @@ class algorithmVisualiser{
297297
for(let i = 1; i < self.dataSet.data.length; i++){
298298
let value = self.dataSet.data[i];
299299
let j = i - 1;
300-
self.dataSet.compIndicator = [j, i]; self.dataSet.compCount++;
301300
while(j >= 0 && self.dataSet.data[j] > value){
301+
self.dataSet.swapIndicator = []
302+
self.dataSet.compIndicator = [j, i]; self.dataSet.compCount++;
302303
self.dataSet.data[j + 1] = self.dataSet.data[j];
303-
self.dataSet.swapIndicator = [j, j+1]; self.dataSet.swapCount++;
304304
j = j - 1;
305305
await self.wait(self.options.delay);
306306
}
307+
self.dataSet.swapIndicator = [j + 1, i]; self.dataSet.swapCount++;
308+
self.dataSet.compIndicator = [];
307309
self.dataSet.data[j + 1] = value;
308310
await self.wait(self.options.delay);
309311
}

0 commit comments

Comments
 (0)