dsu tree in cpp and ruby