Q1 of linked list quiz

sir i am not able to understand why the answer is A . as we are given the L pointer pointing to last element so for deleting it we just have to make L point to null .

Question :

Q1. Delete In A Linked List
Consider a singly linked list of the form where F is a pointer to the first element in the linked list and L is the pointer to the last element in the list. The time of which of the following operations depends on the length of the list?

Delete the element from the last

Delete the element from first

Add an element to the last

Interchange the first two elements

just because for deleting the last element u have to traverse the whole list from starting…

Sir but it is mentioned that we are given the pointer to last element so I don’t think we need to traverse whole list for last element .
And if we need to traverse for deletion then why not for insertion at last , as there also we would need to transverse for last element pointer to change it from NULL to new last element node.

basically for insertion we can directly add node to the next of last pointer and assign newly added node as last pointer…
but for deletion there is pointer to last node and not to second last node… so how will u make secondlast node->next = NULL… for that u would have to traverse the linked list

Isn’t pointer to the last node is actually the second Last node. As second Last node always points to last node.

what are are saying is correct that second last node points to last node… but there is an additional L pointer which is pointing only to the last node…

do u still have any doubt???

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.