Those are complicated questions, which have changed over the course of history.
Before naval aviation, the smallest vessel that was to be sent solo was a cruiser. Since those vessels might be sent to trouble spots, Cruisers and Battleships embarked a Marine Company (around 150-200 personnel). There would also be a similar-sized group of sailors on the ship designated as the Naval Landing Force.
For Surface Action, the Marines were assigned an after turret to man entire, from loaders in the magazine, to the shell and charge handlers in the barbette, to the actual crew in the turret assigned. It was a point of pride that the Marines would excel in Ship's Gunnery when exercised and tested.
When the Washington Treaties confined ship sizes, the deployed number of troops changed, sometimes limited to just a couple of Platoons (changes in manning requirements for the guns also affected this).
Once aviation became a significant part of naval operations, ships of all types bristled (to the limits of metacentric stability) with guns in various calibers. These guns were manned by the whole crew, cooks, clerks, yeomen, bosun and the like.
It's mete to point out that the proper manning of a single 20mm is three, the Gunner; and 2 loaders passing magazines from the ready-use lockers to the gun (the close one doubling as a spotter). A 40mm twin mount needed 10--Gun Captain; pointer (elevation); trainer (azimuth); 2 close loaders per breech; 2 off-mount loaders passing ready-service and racked ammo; and a Talker on sound-powered phones. Which got very crowded in a quad mount. Then, there was a Gun Director, typically 1 per 1.5 mounts.
With Flight Crew, that's complicated, too. You do not always launch the entire Air Wing in every operation. You might only sortie a quarter of the ground-attack or anti-ship aircraft, the better to have follow-up waves. You also needed to reserve some fighters for your own Combat Air Patrol to fend off any aerial attackers.
The toughest GQ/BS Quarters are with the snipes--the engineering staff has to be on duty and ready to do what ever it takes to keep everything working. And the off-duty snipes were often needed to run the full plant right at its maximum limits.
Second worst GQ station is Damage Control parties. Your job there is to be at your assigned DC station, doing nothing at all, unless something happens. So you get to stand, or crouch in a passageway only able to see the metal walls around you while the ship maneuvers about. The Talker can hear whatever traffic is on the JA, but that might not be very much, and you can't "scan" the 1JV or XJA while waiting to see if you are waiting it all out.