O(1) is correct...bcoz pointer for initial node is already known ....no need to traverse.....
Answer-O(n) bcz in question only say about insert at starting of list (http://vle.du.ac.in/mod/book/view.php?id=5704&chapterid=2629)
@ Mr_22B If the node we want to insert contains the array of n elements then?
as last node will hold the address of first node means point to the head pointer....
now during the insertion of new node we will change head pointer to the new one ...as a result head will point to the new node as well as last node will also point to head node.......
i think her no need to...traverse cahnge the last node->next address.....?????
If you have pointer to the first node
Insertion at beginning: O(n)
Insertion at the end: O(n) // As you have to traverse till the end.
If you have pointer to the last node
Insertion at beginning: O(1)
Insertion at end: O(1)
Check this: https://gateoverflow.in/1033/gate2004-36