Defense HTK = (Troop HP) / (defense damage per shot), rounded up.
Offense HTK = (Building HP) / (Damage per Troop Attack), rounded up.
HTK stands for "Hits To Kill". Note that this table lists the number of HITS a particular defensive structure requires to be destroyed, not the number of SECONDS (many troops do not attack at a rate of once per second).
The Inferno Tower is a special case, as its damage increases the longer it attacks a single target. For the purposes of this table, it is assumed that the Inferno Tower attacks the unit in question continuously until the unit dies. The Inferno Tower's damage per shot is currently calculated as follows:
(damage per attack) = (initial DPS) * (attack speed) * 1.1 ^ (number of shots fired - 1)
For example: Level 2 after 3 seconds = 30*0.128*1.1^((3/0.128)-1) = approximately 32.59
This formula seems to closely correlate to the initial, 2-second and 5-second DPS numbers reported. However, if it is later determined that the damage ramp-up follows a different formula, these numbers will be updated.