Which among these two code will be more preferred for deletion of head node of a linked list and why? what is the use of allocating memory to temp , if we want to delete it ,eventually?
code-1:
void Delete_at_Front() {
if (head == NULL) return;
else {
Node *temp = head;
head = head -> next;
delete temp;}
}
code -2 :
void Delete_at_Front() {
if (head == NULL) return;
else {
head = head -> next; }
}
Aucun commentaire:
Enregistrer un commentaire