By late May you are going to be in the high season at Yosemite Valley. Memorial Day is Monday, May 27 so if your dates overlap that weekend you will face holiday crowds as well. At such times you should expect
no campsite availability in the Yosemite Valley unless you've already reserved it well in advance. The spots held for "walk in" arrivals will have long lines of visitors waiting for them starting as early as a few hours before dawn. You might luck into finding a spot but I wouldn't plan a major trip around getting that lucky!
Dispersed camping is definitely a way to go in such a situation. Understand that you must do it
outside the park, though. Inside the park, camping is only allowed in designated sites. No camping in parking lots, along the side of the road, or 50' off the road on that neat little dirt pull-out. Go outside the park to one of the national forests, however, and the rules loosen considerably. But there are still rules! For example, you have to maintain certain distances away from paved roads, established day-use sites, rivers and ponds, and other sensitive areas. You will also need a campfire permit if you plan to do anything that involves a fire-- including using small gas cook stove. Here's an example of dispersed camping guidelines in the area:
https://www.fs.usda.gov/detailfull/s...telprdb5121831. Read these in advance and then plan to visit a National Forest ranger station for permits and up-to-date restrictions when you arrive.