DSA Poster (1) Ansh

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Applications:

Shell sort: 1.Replacement for insertion sort, where it takes a long time
to complete a given task.
Shell sort is mainly a variation of Insertion Sort. In insertion sort,
2. To call stack overhead we use shell sort.
we move elements only one position ahead. When an element
3. when recursion exceeds a particular limit we use shell sort.
has to be moved far ahead, many movements are involved. The
4. For medium to large-sized datasets.
idea of ShellSort is to allow the exchange of far items. In Shell
5. In insertion sort to reduce the number of operations.
sort, we make the array h-sorted for a large value of h. We keep
reducing the value of h until it becomes 1. An array is said to be
h-sorted if all sublists of every h’th element are sorted.
1. Disadvantages:

Shell Sort Algorithm: • Complexity: Shell sort has a more complex


implementation compared to simpler sorting
Step1−Start algorithms such as bubble sort and selection sort.
Step 2 − Initialize the value of gap size. Example: h
• Not stable: Shell sort is not a stable sorting algorithm,
Step 3 − Divide the list into smaller sub-part. Each must have
equal intervals to h meaning that it does not preserve the order of equal
Step 4 − Sort these sub-lists using insertion sort elements in the input data.
Step 5 – Repeat this step 2 until the list is sorted. • Non-optimal worst-case performance: While Shell sort
Step6–Print a sorted list. Step 7 – Stop. performs better than many sorting algorithms on
Advantages: average, its worst-case performance is still O(n^2),
which could be more optimal
• Efficiency: Shell sort has faster average-case
performance than many other sorting algorithms such
as bubble sort and selection sort.
.
• In-place sorting: Shell sort can be implemented as an
in-place sorting algorithm, meaning that it does not Mr. Ratnesh K. Choudhary
require additional memory space for sorting.
(Subject Teacher DSA)
• Adaptive: Shell sort is adaptive in nature, meaning that
it can adjust its performance depending on the input
data. For example, if the input data is almost
sorted, the algorithm will perform faster than if Name: Ansh Mishra
the data is completely unsorted.
Roll no:CS22078
Section: B
Year/Branch: 2nd/CSE

You might also like