0% Completed
I have 17 years of experience in Programming and Data Science working for big tech companies like NVIDIA and Bloomberg. I also run a famous YouTube channel called Codebasics where I pursue my passion for teaching. Codebasics is one of the top channels on YouTube when it comes to data science, machine learning, data structures, etc. I firmly believe that “Anyone can code” and I use analogies, simple explanations, and step-by-step storytelling to explain difficult concepts in such a way that even a high school student can understand them easily.
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
New here? Create an account
By logging in, you agree to our Terms and Conditions and Privacy Policy.
Already have an account? Sign in
By continuing, you are agreeing to Codebasics' Terms and Conditions and Privacy Policy.
Please enter the OTP sent to your email ID.