πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!


    Question

    Given a singly linked list with 'n' nodes, what is the

    time complexity to delete the last node?
    A O(1) Correct Answer Incorrect Answer
    B O(log n) Correct Answer Incorrect Answer
    C O(n) Correct Answer Incorrect Answer
    D O(n log n) Correct Answer Incorrect Answer
    E O(n^2) Correct Answer Incorrect Answer

    Solution

    Answer: C) O(n) To delete the last node, you need to traverse the list to find the second-to-last node, which takes O(n) time.

    Practice Next
    ask-question
    9