Jump to content

Array sorting formula.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
joninty

joninty

    Newbie

  • Members
  • Pip
  • 5 posts
I have essentially an array sorting problem. I know there are multiple algorithms for this but I'm looking for a FORMULA based in the FASTEST algorithm:

If I own cars in a garage with 100 spaces.

i) Whats the minimum moves to order by age?

ii) If I buy another car how long does it take to add to the collection, preserving order.


iii) How does i) and ii) change if I order by color and have X colors?

Thanks.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Sorting algorithm - Wikipedia, the free encyclopedia
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
joninty

joninty

    Newbie

  • Members
  • Pip
  • 5 posts
Cheers but I had read this already. I'm interested in a formula that describes the minimum possible moves.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
It is dependent on the algorithm used, and for some algorithms the current ordering. In general, sorting algorithms are at least O(n log(n)).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
mrhbrandi

mrhbrandi

    Newbie

  • Members
  • PipPip
  • 17 posts
hi,

Try the solution provided at :

Array sort formula - Software Design and Algorithms