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
B new_node.next = head
C new_node.next = head.next
D head.next = new_node
E new_node.next = None
Practice Next

Hey! Ask a query