Neha Singhi Interview Question

How to implement the trees using the graphs