| > Radix sort is theoretically O(N), Nothing theoretical about it: Sorting a list of all IP addresses can absolutely and trivially be done in O(N) > in reality you can't do better than O(log N) You can't traverse the list once in <N so the complexity of any sort must be ≥N. > but memory access is logarithmic No it's not, but it's also irrelevant: A radix sort doesn't need any reads if the values are unique and dense (such as the case IP addresses, permutation arrays, and so on). > Edit: I misremembered, memory access is actually O(sqrt(N)): https://github.com/emilk/ram_bench It's not that either. The author ran out of memory; They ran a program that needs 10GB of ram on a machine with only 8GB of ram in it. If you give that program enough memory (I have around 105gb free) it produces a silly graph that looks nothing like O(√N): https://imgur.com/QjegDVI The latency of accessing memory is not a function of N. |
This is not generally relevant for PCs because the distance between cells in the DIMM does not affect timing; ie. the memory is timed based on worst-case delay.