The figure shows a metal spring being heated with a flame. The spring had previously been stretched out of shape, and as it is heated it pulls itself back into its original coiled form without any force being applied. What class of material is this, and what is happening?

A. A composite, in which two bonded materials pull against one another as they are heated
B. A shape memory alloy, which recovers its original shape when heated after having been plastically deformed
C. A piezoelectric material, which changes shape in response to an applied electrical current
D. A hygroscopic material, which changes shape as it absorbs moisture from the surrounding air
