Its probably the same as in hotels. They have a time they start at based on the general ship schedule. For example, at Castaway Cay, they know the majority of the passengers will be off the ship by x time or the majority of the passengers at X port have early breakfast and all day excursions.
They probably just start at the first room on their list, and then as they are in the corridors, they can see which rooms have movement, which rooms have a family but only 1 adult has left, so they skip that, then they see the couple from 2 rooms down leaving with a day bag, so they are out for an excursion, etc etc.
There is probably a window when all the rooms are empty so they know, right lets get as much done during that time.
Ships, like hotels have routines , so after 2 cruises, the room attendants will start to see patterns of how guests move from area to area, and then like everything it will just become automatic to them to look for various signs and indications of whether a room is occupied or not.