Let's say that I have some files on a hard drive (the data for each file is represented by a different letter):
xxxoooozzzz--------------------
Now let's say that I delete file Z without securely wiping it. The file will still be on the hard drive until something overwrites it:
xxxoooozzzz--------------------
Now let's say that I decide to create a new file (b). This will take up some of the remaining space on the hard drive. My question is, does the hard drive or operating system take the deleted files into account when deciding where to put the data for the new files?
From a convenience perspective, it seems like it would be best for the hard drive/OS to intentionally avoid overwriting deleted files, like this:
xxxoooozzzz---------------bbbbb
By doing that, I would have a higher chance of recovering File Z if I later realized that I wanted it back.
From a security perspective, it seems like it would be best to do the opposite and instead prioritize overwriting old files, to help prevent deleted data from being recovered by a malicious third party. For example, like this:
xxxoooobbbbb-------------------
My question is, are either of these things actually taken into account when writing new data? Or is the new write location essentially just random?