I think that the first code is correct, but what you are missing is the code merging adjacent quads. It's normal the vertices of adjacent quads don't overlap.
In particular when they have different resolutions, you need to realize a code that merges quads with 2N with 2N+1 subdivisions, to perform a correct triangulation.
And looking better in your images, you have quads with resolutions 2 (violet), 8 (red) and 32 (green). That's quite strange, since usually when using multi-resolution, it's important to limit adjacent tiles have similar resolutions... you have to handle the triangulation in resolution jumps from 2N to 2N+2.
I mean, I'm surprised that there aren't tiles with 4 and 16-resolution in the middle, but it's just a free observation - it's not wrong in principle, just strange for some experiences I had.