Skip to content

Commit a464be3

Browse files
author
Sadanand Pai
committed
Shell sort edge case fix
1 parent 19af617 commit a464be3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cypress/e2e/home.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('template spec', () => {
1+
describe('landing page', () => {
22
beforeEach(() => {
33
cy.visit('/');
44
});

src/apps/sorting-visualizer/sorting-algorithms/shell.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import {
77
import { SortAsyncGenerator } from '@/apps/sorting-visualizer/models/types';
88

99
export async function* shellSort(array: number[]): SortAsyncGenerator {
10+
if (array.length === 1) {
11+
yield* sort(0);
12+
return;
13+
}
14+
1015
let gap = 1;
1116

1217
while (gap * 3 + 1 < array.length) {

0 commit comments

Comments
 (0)