Bsf23006565 Dsa 3rd Assignment
Bsf23006565 Dsa 3rd Assignment
Assignment#3
Linked List
Name: M.Faizan
Program: BSCS T
Session: Evening T
Section: B T
list.insertAtBeginning(10);
list.insertAtEnd(20);
list.insertAtEnd(30);
list.insertAtEnd(40);
list.insertAtEnd(50);
list.deleteFirstNode();
cout << "List after deleting the first node:\n";
list.display();
list.insertAtPosition(25, 3);
cout << "List after inserting 25 at position 3:\n";
list.display();
return 0;
}
Dry Run:
Starting with an empty list, we first insert at the beginning with 10, making the list 10 -> NULL. Next, we insert at the
end four times: adding 20 gives 10 -> 20 -> NULL, then adding 30 results in 10 -> 20 -> 30 -> NULL, adding 40 results
in 10 -> 20 -> 30 -> 40 -> NULL, and adding 50 gives 10 -> 20 -> 30 -> 40 -> 50 -> NULL. We then delete the first
node, removing 10, so the list becomes 20 -> 30 -> 40 -> 50 -> NULL. Finally, we insert 25 at position 3, changing the
list to 20 -> 30 -> 25 -> 40 -> 50 -> NULL. Each operation modifies the node pointers accordingly, resulting in the final
list structure.