Implemented numLeaves() method