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
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/data/contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ export const dsaContributors = [
role: "Backend Architecture",
github: "https://github.com/jamesw",
avatar: "https://images.unsplash.com/photo-1599566150163-29194dcaad36?w=150&h=150&fit=crop&crop=faces"
},
{
name: "Harshith T S",
role: "Software Developer",
github: "https://github.com/iamHarshithTS",
avatar: "https://avatars.githubusercontent.com/u/192116971?v=4"
}
];
43 changes: 43 additions & 0 deletions src/lib/dsaAlgorithms.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,49 @@ function partition(arr, low, high, steps) {
return (i + 1);
}

export const generateShellSortSteps = (array) => {
const steps = [];
const arr = [...array];
const n = arr.length;

for (let gap = Math.floor(n / 2); gap > 0; gap = Math.floor(gap / 2)) {

for (let i = gap; i < n; i++) {
let temp = arr[i];
let j = i;

steps.push({ type: 'select', indices: [i] });
while (j >= gap) {
steps.push({ type: 'compare', indices: [j, j - gap] });

if (arr[j - gap] > temp) {

steps.push({
type: 'overwrite',
indices: [j],
value: arr[j - gap]
});
arr[j] = arr[j - gap];

steps.push({ type: 'revert', indices: [j, j - gap] });
j -= gap;
} else {
steps.push({ type: 'revert', indices: [j, j - gap] });
break;
}
}
steps.push({ type: 'overwrite', indices: [j], value: temp });
arr[j] = temp;
}
}

// Final pass to mark everything as sorted
for (let k = 0; k < n; k++) {
steps.push({ type: 'sorted', indices: [k] });
}

return steps;
};

// --- Searching Algorithms ---

Expand Down
2 changes: 1 addition & 1 deletion src/pages/DsaVisualization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const DsaVisualization = () => {
};

const algoOptions = {
sorting: ['BubbleSort', 'SelectionSort', 'InsertionSort', 'MergeSort', 'QuickSort'],
sorting: ['BubbleSort', 'SelectionSort', 'InsertionSort', 'MergeSort', 'QuickSort','ShellSort'],
searching: ['BinarySearch', 'LinearSearch'],
graphs: ['BFS', 'DFS', 'Dijkstra', 'AStar'],
linkedlist: [],
Expand Down