I had an interview the other day with Amazon, and a question they asked me was pertaining to the following problem.
Given 2 integer arrays, containing any number of elem
There is no O(1) space method for finding the intersection of two unsorted sets in O(n) time.
For a data type with an unlimited range, the minimum sorting price is O(n ln n).
For a data type with a limited range radix sort provides the ability to do an in-place radix sort in O(n ln n' n") time, where n is the size of the data, n' is the number of values that can be represented, and n" has to do with the cost of checking whether two values are in the same radix group. The n" time price can be dropped in return for an O(ln n) space price.
In the special case of 32-bit integers, n' is 2^32 and n" is 1, so this would collapse to O(n) and provide a winning solution for multi-billion record sets.
For integers of unlimited size, n' and n" preclude an O(n) time solution via radix.