Can anyone give me example about shell sort? I'm a new person in here who must learn about shell sort, but first I must find a Java shell sort example. I found one example in Google but it's too difficult.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to toggle on Order in ReactJS
- StackExchange API - Deserialize Date in JSON Respo
Snippet with 3k+1 gap.
Here is a visualization of shell sort for a python implementation:
Shell sort improves insertion sort by comparing elements separated by a gap of several positions.
This lets an element take "bigger steps" toward its expected position. Multiple passes over the data are taken with smaller and smaller gap sizes. The last step of Shell sort is a plain insertion sort, but by then, the array of data is guaranteed to be almost sorted.
This code might help you in understanding the logic better.
Here is a video link: https://youtu.be/SCBf7aqKQEY The guy has made a good video of shell sort!!
And a simple code:
May be, this java code will help you.
Here, this code is very simple :
I stole it from a book called Data Structures and Algorithm Analysis in Java. It is very good book easy to understand. I advise you to read it.