Write Algorithm For Depth And Weight