Java Shell Sort

Java Shell SortWelcome to my Java Shell Sort tutorial! I really tried to have fun explaining how the Shell Sort works in this tutorial. I show how it works in 4 different ways. We see it graphically, in a presentation format, explained during execution and again in the code itself. Everything can be found after the video.

The Shell Sort is one of the fastest of the easier to understand sorting algorithms. It is similar to the insertion sort, but it has an added feature in which it partially sorts the array before the insertion sort is used. The video and code below will explain everything.

If you like videos like this, it helps to tell Google+ [googleplusone]

Code From the Video

 Java Shell Sort

Java Shell Sort BarExample.java

10 thoughts on “Java Shell Sort”

  1. hey derek, there’s suppose to be a closing bracket at line 014 ???

    010 while (interval <= arraySize / 3){
    011
    012// Define an interval sequence
    013
    014 interval = interval * 3 + 1;

  2. after following the coding in this tutorial i’m getting a program that runs infinitely.

    i think it has something to do with the interval advancement – but wasn’t able to really put my finger on where the problem is.

    and even after the array id perfectly sorted the program keeps on running.

  3. Hi Derek,
    When I first ran your code , it kept repeating inside the first while loop. So I changed the first while loop’s condition into “interval > 0” and it solved the problem. I think after the interval is decremented to 0, we can’t jump out of the first while loop if the condition is “interval <= arraySize/3", because 0 is always less than "arraySize/3". I don't know if my change makes sense.
    Thanks!

    Jack

  4. i said to put the closing bracket at line 014 for the same reason. the loop has to define the interval of 4 only once
    010 while (interval 0) {…
    and then turning to a insertion sort

    this solves the problem, otherwise the program keeps running infinitely.

  5. Hi Derek,

    while (interval <= arraySize / 3)
    // Define an interval sequence
    interval = interval * 3 + 1;

    this is the change i made it is working fine

  6. Derek,

    your tutorial are always excellent , i have one small request can you post multithreading tutorial with concurrency ,it will help us yo clear this concept with your tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *