Sorting algorithms are important in computer science because they help us organize data so it's easier to work with. I'll discuss three sorting alg...
For further actions, you may consider blocking this person and/or reporting abuse
Hey there! While your implementations are correct, there is still room for optimization. Let me share my thoughts with you.
Insertion Sort
currentoutside the inner loop. This avoids reassigning it in each iteration of the inner loop.j>=0for better readabilityj--inside the inner loop.Bubble Sort
swappedvariable declaration outside the outer loop to reset it for each iteration. This will avoid unnecessary iterations when the array is already sorted.i < length - 1to avoid unnecessary iterations. After each pass, the largest element gets placed at the end, so the lastielements are already sorted.Also, your implementations are written in Typescript not Javascript.
Keep up the good work!