0% Completed

Codebasics Icon
Shell Sort - Data Structures & Algorithms Tutorial Python #18

Shell Sort - Data Structures & Algorithms Tutorial Python #18

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://www.youtube.com/redirect?event=video_description&redir_token=QUlxb01IWnBNX0g0cGhCVFBGUmRRUi1QWVljdXxBQnJ0NjltWTZYRE52Qk82QVBURjlkYkFmTHRhUVNiblNSd3Z2cTdEQ21ITEhrVkNmQkVhRVdldTI2dDRJUmdLM04wNExXZklMM3hTb1lsVWpaQ2lmQk11cGE4Z0ExbDd1Y1Aw&q=https%3A%2F%2Fgithub.com%2Fcodebasics%2Fdata-structures-algorithms-python%2Fblob%2Fmaster%2Falgorithms%2F6_ShellSort%2Fshell_sort_exercise.md&v=VxNr9Vudp4Y