What are SN1' and SN2' reactions?

I went through the problems on the pictures:

The answer of the problem 119 is $\mathrm{S_N1'}$, and that of 120 is $\mathrm{S_N2'}$. I actually can't figure out what $\mathrm{S_N1'}$ ($\mathrm{S_N1}$ prime) and $\mathrm{S_N2'}$ ($\mathrm{S_N2}$ prime) are.

Also, how does the answer change by changing the nucleophile?

• I would like to point out that the question is not about nucleophilic substitution in general, in the nutshell it's about the difference that "prime" ' sign adds (e.g. $\mathrm{S_N1}$ vs $\mathrm{S_N1'}$ and $\mathrm{S_N2}$ vs $\mathrm{S_N2'}$), from what I understand. IMO it's neither homework, nor too broad; I cannot find any duplicates, so I'm against closing it for now. Also, check out en.wikipedia.org/wiki/Allylic_rearrangement – andselisk Sep 19 '17 at 17:07
• @andselisk Ah! I missed the prime. I've retracted my vote. O:) – paracetamol Sep 19 '17 at 17:13
• @paracetamol I have a feeling that I saw something related on CSE, but searching for SN1' obviously returns tons of topics where SN1 has been discussed, same with Google. – andselisk Sep 19 '17 at 17:19
• The ' indicates that the actual substitution site is not where the leaving group is attached. In the cases presented, the nucleophile would add at the upper end of the double bond. – Zhe Sep 19 '17 at 17:23

The primed version of $\mathrm{S_N1}$ and $\mathrm{S_N2}$ can only occur if there is a double bond in the vicinity of the leaving group as in your example. I have drawn both possibilities for the $\mathrm{S_N2}$ case in the scheme below.
Scheme 1: Comparison of the reaction products in an $\mathrm{S_N2}$ (top) and $\mathrm{S_N2'}$ (bottom) pathway.
The $\mathrm{S_N2}$ reaction is as you expect it to be. The $\mathrm{S_N2'}$ reaction uses the double bond as an electron relay system. Instead of the nucleophile (here: $\ce{OMe-}$) directly interacting with the $\unicode{x3c3}^*(\ce{C-Br})$ orbital, the π system interacts with the σ* orbital. The nucleophile then interacts with the π system’s LUMO (corresponding to the middle orbital of the allyl π system) to perform the attack. Since the nucleophilic attack and the leaving group are on different carbon atoms, relayed by the π system, this is not a direct $\mathrm{S_N2}$ but a derivative of it ($\mathrm{S_N2'}$).
The same logic can be applied to $\mathrm{S_N1'}$: here, the intermediate carbocation is not a localised one but an allyl cation.
The primed versions here are observed because not only the bimolecular attack on the highly substituted tertiary carbon ($\mathrm{S_N2}$) is unlikely — this carbon is tertiary which usually already implies no $\mathrm{S_N2}$ — but also the capturing of the carbocation under $\mathrm{S_N1}$ conditions is more likely to happen at the sterically much less hindered carbon atom.
As to why methanol predominantly attacks according to an $\mathrm{S_N1}$-type mechanism while methanolate predominantly follows an $\mathrm{S_N2}$-type mechanism I will refer you back to your textbook; the reasons are stated pretty often.