I just rediscovered my favorite Yosemite picture from last year's vacation and thought it is worth to be shared. Amazing how this tree survives on top of this bare rock.
Nice photo.
The tree's roots are likely in a crack(s) in the rock.
The crack has dirt in it and when it rains water saturates the crack.
The crack also keeps sun from evaporating the water.
You can tell the prevailing wind is from the right side of the image because of the way the tree has been forced to grow to the left.
Note the angle near the bottom of the trunk.
I used to climb in Yosemite Valley and we often had to clean dirt out of the cracks so we could securely place the devices we used to clip the safety rope to.