laziness, impatience, and hubris | |
PerlMonks |
Re^2: Algorithom to find overlaping subnets (Internet IPv4)by jimpudar (Pilgrim) |
on Apr 11, 2018 at 05:33 UTC ( [id://1212653]=note: print w/replies, xml ) | Need Help?? |
I recently had to work on this problem, and needed a fast implementation. I found the easiest and fastest way was to use a Trie as mentioned by rg0now. I used the random generator which BrowserUk supplied to generate the random dataset. My version processed the dataset in less than two seconds on my 3.8GHz Linux box. I don't have nice sorted output though. It should be trivial to build up a data structure as you go if you need sorted output... Here's the code:
Some truncated sample output:
Anyone see any issues with this? It hasn't been completely battle tested yet :) Best, Jim
In Section
Seekers of Perl Wisdom
|
|