ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!

  • google app store apple app store
  • тЬЦ

      Question

      What is the time complexity for performing `push` and

      `pop` operations on a stack implemented using a linked list?
      A O(n) for both Correct Answer Incorrect Answer
      B O(log n) for both Correct Answer Incorrect Answer
      C O(1) for both Correct Answer Incorrect Answer
      D O(1) for push, O(n) for pop Correct Answer Incorrect Answer
      E O(n) for push, O(1) for pop Correct Answer Incorrect Answer

      Solution

      When a stack is implemented using a linked list, `push` (adding to the head) and `pop` (removing from the head) operations can be performed in constant time, O(1), by simply manipulating pointers.

      Practice Next
      More Data Structure Questions
      ask-question