I’m not sure I understand the question. The Z wave controller, in this case the smartthings hub, gives out the IDs when devices join the network. They are just given in numerical order, 5, 6, 7 etc. IDs for deleted devices can be reused, but not until the network has reached the maximum of 232. Then it goes back to the beginning and starts giving out the leftover no longer being used IDs, again in order.
The table of IDs is kept in the hub itself. In the smartthings architecture, The cloud tries to keep up, but it can lag a little bit behind.
There is one weird exception. If you are using the smartthings Wi-Fi mesh system, there was a glitch where the subhubs might always be identified as an “unknown device,” even though they could act as repeaters. To be honest I don’t really know much about the details of that except that the issue has been reported in the forum multiple times.
Other than that, if it’s a ghost device, that means it’s a device that was kicked off the network but somehow all the housekeeping didn’t get done and so either you are looking at an old route record, which can happen, or the cloud doesn’t know exactly what is going on.
I don’t know how all that matches up with the question you were asking, though, but since device IDs don’t change, that is they don’t get reused unless you’ve gotten all the way up to the maximum and are cycling through again, it’s not likely that you deleted the “wrong“ device.
But again, I’m not sure I understand the question.