Sure, here's a simple algorithm to achieve that:
1. Fill the 5-litre jug.
2. Pour water from the 5-litre jug into the 3-litre jug until it's full.
3. Now, the 5-litre jug has 2 litres of water (5 - 3).
4. Empty the 3-litre jug.
5. Pour the remaining 2 litres from the 5-litre jug into the empty 3-litre jug.
6. Fill the 5-litre jug again.
7. Carefully pour water from the 5-litre jug into the 3-litre jug until it's full. This will leave exactly 4 litres in the 5-litre jug.
This algorithm ensures you measure exactly 4 litres in the 5-litre jug using only the 3-litre and 5-litre jugs.