PTC Interview Question

function to calculate height of tree