Is a resistor compulsory in a NOT gate made from an NPN transistor?
Without the resistor, it is impossible for the output to be at any voltage other than that of the VCC supply rail, to which it is then directly wired.   All the transistor can do in such a case is short out the power supply.
What you drew in the first picture is called &quot;resistor transistor logic&quot; as it depends on a pulling resistor to counterbalance the transistor and provided the limited drive in the other direction.  But it wastes power (in the resistor) in one state, and it is slow in the direction where the resistor sources current.
More typically, &quot;transistor transistor logic&quot; was used - there other transistors would function to drive the output high when needed, or to act like the resistor does as something of a current source.`  But that's largely faded from use.
Today most logic is CMOS - Complementary Metal Oxide Semiconductor.  It is made of field-effect transistors with oxide-insulated gates.  And it is &quot;complementary&quot; because there's an approximate mirror image to the schematic, with an upper P-channel FET and a lower N-channel FET which work alternately to drive the signal high or low.