Let A be the speed of hiker A and B the speed of hiker B.
let's say that B is faster than A, so B=A+0.5
we know that they met after 2 hours, and the distance each walked after 2 hours is given by:

One of the hikers travels at 4 miles per hour, the other one at 4.5 miles per hour