Gravity Sort : Is this possible programatically?
Posted
by Bragaadeesh
on Stack Overflow
See other posts from Stack Overflow
or by Bragaadeesh
Published on 2010-03-21T23:15:18Z
Indexed on
2010/03/21
23:21 UTC
Read the original article
Hit count: 384
Hi,
I've been thinking recently on using the Object Oriented design in the sorting algorithm. However I was not able to find a proper way to even come closer in making this sorting algorithm that does the sorting in O(n) time.
Ok, here is what I've been thinking for a week. I have a set of input data. I will assign a mass to each of the input data (assume input data a type of Mass). I will be placing all my input data in the space all at same distance from earth. And I will make them free fall. According to gravitational law, the heaviest one hits the ground first. And the order in which they hit will give me the sorted data. This is funny in some way, but underneath I feel that this should be possible using the OO that I have learnt till date
Is it really possible to make a sorting technique that uses gravitational pull like scenario or am I stupid/crazy?
© Stack Overflow or respective owner