Answer ancestor-walk queries on a rooted tree | Others Interview Question