dshrenik
asked on
Sorting alogorithm
Please tell me which sorting algorithm is most efficient when the data:
1. has very few unique elements
2. is in reverse sorted order.
Also, please tell me the complexity in each case.
Thanks!
1. has very few unique elements
2. is in reverse sorted order.
Also, please tell me the complexity in each case.
Thanks!
Read something like this :
http://en.wikipedia.org/wiki/Sorting_algorithm
If you need more detailed info you will have to provide sample data or more information.
The question sounds a bit like an exam or homework question. if this is the case you are supposed to specify that.
http://en.wikipedia.org/wiki/Sorting_algorithm
If you need more detailed info you will have to provide sample data or more information.
The question sounds a bit like an exam or homework question. if this is the case you are supposed to specify that.
ASKER
Its not a homework problem. I'm preparing for an interview.
I'm trying to identify the best algorithm for various scenarios:
When values are in a small range - Bucket sort
Nearly sorted - Insertion sort, etc.
I'm trying to identify the best algorithm for various scenarios:
When values are in a small range - Bucket sort
Nearly sorted - Insertion sort, etc.
As above the links tell you all there is to know about sorting. The formulas give you the rough time / memory / number of steps it takes to sort the field as the size etc increases.
You need to understand the idea of things like 'the big O'
If you understand that and you are able to code the basic sort functions then you can talk about it in an interview.
read, read, read....
You need to understand the idea of things like 'the big O'
If you understand that and you are able to code the basic sort functions then you can talk about it in an interview.
read, read, read....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here: http://warp.povusers.org/SortComparison/