In data structures, what does push do?

  • ARemoves the first element
  • BAdds an element to the end
  • CRemoves the last element
  • DAdds an element to the beginning
Show answerHide answer

Correct answer B

In stack data structures, push is used to add an element. The element is added to the top of the stack (end of the structure). The opposite operation is pop, which removes the top element. Stacks follow the LIFO (Last In, First Out) principle. Push helps in storing data temporarily during computations and function calls.