ЁЯУв 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