Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Lecture-048/2_Remove_Duplicates_In_Unsorted_Linked_List.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ void removeNodes2(Node* &head) {
}
}
}
//function for deleting heap allocated memory for all nodes in Linked List after its use
void delete_LL(Node* &head){
Node* temp;
while(temp->next!=NULL){
temp=head;
head=head->next;
delete temp;
}
delete temp;
}

int main() {
Node *head = new Node(1);
Expand All @@ -180,11 +190,8 @@ int main() {
insertAtTail(tail, pow(2,2));
insertAtTail(tail, pow(2,9));
insertAtTail(tail, pow(2,9));

printList(head);

removeNodes1(head);
printList(head);
delete_LL(head);

return 0;
}
Binary file not shown.