๐Ÿ“ข Too many exams? Donโ€™t know which one suits you best? Book Your Free Expert ๐Ÿ‘‰ call Now!


    Question

    Complete the insert_at_beginning function for a singly

    linked list. Assume Node has data and next attributes. class Node: ย  ย  def __init__(self, data): ย  ย  ย  ย  self.data = data ย  ย  ย  ย  self.next = None def insert_at_beginning(head, new_data): ย  ย  new_node = Node(new_data) ย  ย  _________ # Line to complete ย  ย  return new_node # new_node becomes the new head
    A head = new_node Correct Answer Incorrect Answer
    B new_node.next = head Correct Answer Incorrect Answer
    C new_node.next = head.next Correct Answer Incorrect Answer
    D head.next = new_node Correct Answer Incorrect Answer
    E new_node.next = None Correct Answer Incorrect Answer

    Solution

    The correct answer is B

    Practice Next
    More IT Operating System Questions
    ask-question