The US requires smoke detectors on every habitable level and within the vicinity of all bedrooms. Habitable levels include attics that are tall enough to allow access.
In new construction, minimum requirements are typically more stringent. All smoke detectors must be hooked directly to the electrical wiring, be interconnected and have a battery backup. In addition, smoke detectors are required either inside or outside every bedroom, depending on local codes. Smoke detectors on the outside will detect fires more quickly, assuming the fire does not begin in the bedroom, but the sound of the alarm will be reduced and may not wake some people. Some areas also require smoke detectors in stairways, and main hallways.
Wired units with a third "interconnect" wire allow a dozen or more detectors to be connected, so that if one detects smoke, the alarms will sound on all the detectors in the network, improving the chances that occupants will be alerted, even if they are behind closed doors or if the alarm is triggered one or two floors removed from their location. Wired interconnection may only be practical for use in new construction, especially if the wire needs to be routed in areas that are inaccessible without cutting open walls and ceilings.