Application of recursion in data structure