📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    What is the time complexity of the peek operation

    (accessing the top element without removing it) in a stack implemented using a singly linked list?
    A O(N) Correct Answer Incorrect Answer
    B O(log N) Correct Answer Incorrect Answer
    C O(1) Correct Answer Incorrect Answer
    D O(N log N) Correct Answer Incorrect Answer
    E O(N^2) Correct Answer Incorrect Answer

    Solution

    In a singly linked list implementation of a stack, the top of the stack is typically represented by the head of the list. Accessing the head element (peek operation) takes constant time, O(1).

    Practice Next
    ask-question