Results 1 to 3 of 3
Thread: Hibbard's Shell Sort
- 11-12-2009, 05:58 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
Hibbard's Shell Sort
I have gotten down shell sort algorithms, but i just cant get Hibbard's increments. I get what they are, I just cant implement them into my basic shell sort. For other shell sorts, they go while gap>0, but with Hibbard it's counting up... when does it stop?? i figure if it goes while gap<array.length, the gap will eventually over shoot the end of the array?? please help!!
- 11-12-2009, 07:54 PM #2
I just checked out the wikipedia page on it and from this pseudocode
I'm assuming is the basis of what you're working with. Hibbard's sequence is 2x+1 all the way from 1 to array.length correct?Java Code:input: an array a of length n with array elements numbered 0 to n − 1 inc ← round(n/2) while inc > 0 do: for i = inc .. n − 1 do: temp ← a[i] j ← i while j ≥ inc and a[j − inc] > temp do: a[j] ← a[j − inc] j ← j − inc a[j] ← temp inc ← round(inc / 2.2)
If you're going while gap < array.length and incrementing up then it should stop before you reach an index out of bounds.Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 11-12-2009, 08:38 PM #3
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Using Merge Sort to sort an ArrayList of Strings
By coldfire in forum New To JavaReplies: 3Last Post: 03-13-2009, 01:03 AM -
Bean Shell
By Bisweswar in forum Advanced JavaReplies: 2Last Post: 08-16-2008, 12:36 AM -
How to sort a list using Bubble sort algorithm
By Java Tip in forum AlgorithmsReplies: 3Last Post: 04-29-2008, 08:04 PM -
Shell Sort in Java
By Java Tip in forum AlgorithmsReplies: 0Last Post: 04-15-2008, 07:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks