TADM2E 4.40

From Algorithm Wiki
Revision as of 21:47, 8 September 2015 by Bogdandumitrescu (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

For a known set of integer numbers ( assume Nr-1, Nr-2 ... Nr-k) the best is to use Comparison Sort with O(n)

You have an array that creates a histogram of all numbers ( histoThenStartIndexArray[Nr-i]++)

Step 2, in the same array calculate the index of that position For example if there are 3 numbers 99, and 5 numbers 105, the next index will be 8 for the next number

Step 3, parse array and display values