File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -103,11 +103,16 @@ async function insertionSort(array) {
103
103
document . getElementById ( "iterations" ) . innerHTML = swaps ;
104
104
document . getElementById ( "time" ) . innerHTML = time ;
105
105
}
106
+ updateVisualisation ( array ) ;
107
+ isRunning = false ;
108
+ if ( isSorted ( array ) ) {
109
+ document . getElementById ( "isSorted" ) . innerHTML = "True" ;
110
+ }
106
111
}
107
112
108
113
async function selectionSort ( array ) {
109
114
let currentTimestamp = new Date ( ) . getTime ( ) ;
110
- for ( let i = 0 ; i < array . length - 2 ; i ++ ) {
115
+ for ( let i = 0 ; i < array . length - 1 ; i ++ ) {
111
116
minmalElementIndex = i ;
112
117
for ( let j = i + 1 ; j < array . length ; j ++ ) {
113
118
if ( gotReset ) {
@@ -132,6 +137,12 @@ async function selectionSort(array) {
132
137
array [ minmalElementIndex ] = array [ i ] ;
133
138
array [ i ] = tmp ;
134
139
}
140
+ if ( array )
141
+ updateVisualisation ( array ) ;
142
+ isRunning = false ;
143
+ if ( isSorted ( array ) ) {
144
+ document . getElementById ( "isSorted" ) . innerHTML = "True" ;
145
+ }
135
146
}
136
147
137
148
function reset ( ) {
You can’t perform that action at this time.
0 commit comments