[BangPypers] Country look up for an IP address

Saju Pillai saju.pillai at gmail.com
Thu Feb 19 11:41:41 CET 2009

Chetan Nichkawde wrote:
> Dear BangPypers,
>    There was a problem posed to me to efficiently find the country for a 
> given IP address. I have devised the solution for the same using splay 
> tree. This could used in various places, like serving a web pages based 
> on the country from which the request is coming from. The code can be 
> downloaded from

This is interesting.

One point to note concerning the example use of "serving web pages based 
on country". If your server load is generated from throughout the world, 
you will waste time rotating the tree to provide MRU access. Splay trees 
work best when you expect MRU behaviour, behaviour degrades if tree 
nodes are accessed randomly - there is no benefit to moving recently 
accessed nodes upwards to the root.

That being said, there must be lots of MRU patterns in various apps 
where this implementation can be used.


More information about the BangPypers mailing list