memory – Does a factory reset also format device, or just delete and remove indexes?

I am just wondering when using the option erase all content and data how this is done from a system side, does it format a partition on the memory or does it just delete it remove indexes like a normal delete? I would imagine the system files are pretty much untouched? Example scenario I am imagining here is;

A] system partition 2GB ish
B] recovery partition, no idea
C] user space, everything else

So when a factory reset happens does C have it’s data deleted or just totally formatted?
If the later would it skip empty cells on a format?

For example Joe Bloggs gets a new iPhone, usage is 20gb/120gb. 3 days later factory resets it, does it use one of the flash memories finite writes on the entire partition using limited writes or skip over it and write over just the 20gb? I am assuming here that the memory in each iPhone cell can take around 20,000 wipes anyway, so would each cell go down to around 19,999 on average or just the cells that used to have data on before the format if there is one?