Program works as a Binary search tree perfectly now.