To determine the stream's speed, we represent it as \( x \) km/hr.
Given information:
- David's speed in still water is 5 km/hr.
- Let the journey distance downstream and upstream be \( d \) km.
- Downstream travel time is \( \frac{d}{5+x} \) hours.
- Upstream travel time is \( \frac{d}{5-x} \) hours.
- The upstream journey takes three times longer than the downstream journey.
This yields the equation:
\[\frac{d}{5-x} = 3 \times \frac{d}{5+x}\]
After canceling \( d \) from both sides:
\[\frac{1}{5-x} = \frac{3}{5+x}\]
Cross-multiplication results in:
\[5+x = 3(5-x)\]
Expanding and simplifying the equation:
\[5+x = 15-3x\]
\[4x = 10\]
\[x = 2.5\]
Therefore, the speed of the stream is 2.5 km/hr.