Both the containers contain liquid up to the same height, and they're connected by a tube.
If the liquid in the container A is heated, which direction should the water flow in? And similarly, if the container B is heated, which direction will the liquid flow then?
We have to assume that the shape of the containers is not affected by the heating of liquid.
$$$$ What I've been thinking is this: Consider a cylindrical container containing a liquid. It is easy to see that weight of liquid divided by the area of the base of the container is pressure at the bottom. Since neither the area nor the weight of the liquid changes on heating, the pressure remains constant. And since, $P = \rho g h$, it means that here $\rho h$ remained constant, density decreases, but height increases. But, for containers that aren't shaped like cylinders, I'm facing problems to see how the change in height would react with the change in density. Because this is not free expansion, and is restricted by the container too, I thought, it wouldn't be correct to assume the change in height as a linear relation for both the containers. What should I be thinking instead? I also am not sure about the answer to this problem, although, the answer given is this: In both cases, liquid flows from B to A.