Shell sort

Shell sort
}  The shell sort, is also known as the “diminishing increment sort”.
}  The shell sort proposed by Donald L Shell in 1959.
}  Divides an array into several smaller non-contiguous segments.
}  The distance between successive elements in one segment is called gap.
}  Each segment sorted with in itself using insertion sort.
}  Then resegment into larger segments and repeat sort.
}  Continue until only one segment (gap=1).

Example:
Before sorting the given array list is  a= {80, 93, 60, 12, 42, 30, 68, 85, 10}
First Increment factor = (total no.of elements / 2) = (9/2) = 4
=>  (a1,a5,a9)  (a2,a6)  (a3,a7)  (a4,a8)
=>  (80,42,10)  (93,30)  (60,68)  (12,85)
   Apply insertion sort

=> (10,42,80)  (30,93)  (60,68)  (12,85)

Share on Google Plus
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment