Link to home
Start Free TrialLog in
Avatar of dshrenik
dshrenikFlag for United States of America

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!
Avatar of rawinnlnx9
rawinnlnx9
Flag of United States of America image

Come on. This is homework. Go read up on Big O notation and binary trees. 20 minutes of light reading and you should be able to figure this out.

Here: http://warp.povusers.org/SortComparison/
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.
Avatar of dshrenik

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.
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....
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial