Minkowski distance with Missing Values
The way you type formulas is a bit confusing, but here's a go at interpeting it.

Euclidean distance is defined by:



Manhattan distance is defined by:



Handling missing terms is an independent issue. The way it is handled in the example is by taking the average of the present features (dividing by their number) and multiplying by the total number of features as a way to bring the data to a scale comparable to datapoints without missing features.

Now let's have a closer look at the example. The total number of features is 4. To calculate a distance between datapoints you can only use features that are present in both:


The first (Euclidean) formula finds 3 features present in both x1 and x2. Thus your coefficient is 4/3.
The second (Manhattan) formula finds two features present in both x3 and x4. Thus the coefficient is 4/2.