Taking input of tree

how to make tree if input is given like
3
1 2
2 3
like in graph if edge is given ??

hey @Ashu1318
If input is given like this way then what u can do is create n nodes of tree and put them in a map
where key is i and node is reference to ith node
then according to input edges connect them using hashmaps