Shell sort is a customization over insertion sort. Insertion sort requires many swaps and comparisons if heavy elements are located towards the end of an array. Shell sort will initially sort subarrays that are equal distance apart. The distance here is referred to as a gap. We will than keep on reducing the gap until it is 1. With gap=1 it becomes insertion sort but this time due to optimization we have performed earlier, sorting the array would require very less comparisons and element swaps.
Code: https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/6_ShellSort/shell_sort.py
Exercise: https://github.com/codebasics/data-structures-algorithms-python/blob/master/algorithms/6_ShellSort/shell_sort_exercise.md
Data structures and algo in python playlist: https://www.youtube.com/playlist?list=PLeo1K3hjS3uu_n_a__MI_KktGTLYopZ12
🔖Hashtags🔖
#Shellsort #datastructures #algorithms #python #Shellsortpython #sortalgorithm #pythonShellsort #Shellsort #datastructure #Shellsortcode #Shellsortprogram
Do you want to learn technology from me? Check https://codebasics.io/ for my affordable video courses.
Website: http://codebasics.io/
Facebook: https://www.facebook.com/codebasicshub
Twitter: https://twitter.com/codebasicshub
Linkedin: https://www.linkedin.com/company/codebasics/
Discord: https://discord.gg/r42Kbuk
DISCLAIMER: All opinions expressed in this video are of my own and not that of my employers'.