Question: What is the runtime complexity of adding an item to a stack and removing an item from a stack?

  1. Add items to a stack in O(1) time and remove items from a stack on O(n) time.
  2. Add items to a stack in O(1) time and remove items from a stack in O(1) time.
  3. Add items to a stack in O(n) time and remove items from a stack on O(1) time.
  4. Add items to a stack in O(n) time and remove items from a stack on O(n) time.

Answer: The correct answer of the above question is Option B:Add items to a stack in O(1) time and remove items from a stack in O(1) time.