ADSA 3rd
ADSA 3rd
Experiment 1.3
Student Name: UID:
Branch: Section/Group:
rd
Semester: 3 Sem Date of Performance:
Subject Name: Adv. Data Structure & Algorithm Subject Code: 23CSH-204
1. Aim: In a college's alumni association, two separate lists of alumni donations are
maintained. The first list contains the funds donated by alumni in a specific order, and
the second list represents another group of alumni with their donation numbers. Due to
some inconsistencies in the records, every third donation in the first list is found to be
erroneous and needs to be removed.
You are tasked with cleaning up the first list by removing every third donation. After
that, you need to identify the common donation number between the cleaned first list and
the second list. This will help the association identify alumni who have donated multiple
times.
2. Requirements(Hardware/Software):
C++ compiler.
3. Procedure:
#include <iostream>
struct Node {
int val;
Node *next;
};
else {
Node* temp = head;
int count = 1;
while (curr) {
if (count % 3 == 0) {
prev->next = curr->next;
delete curr;
curr = prev->next;
} else {
prev = curr;
curr = curr->next;
count++;
while (list1) {
while (temp) {
if (list1->val == temp->val) {
break;
temp = temp->next;
}
list1 = list1->next;
while (head) {
head = head->next;
int main() {
append(list1, val);
append(list2, val);
deleteEveryThird(list1);
cout << "First linked list after deleting every third node:\n";
printList(list1);
cout << "Common values between the two linked lists:\n";
printCommon(list1, list2);
return 0;
4. Output:
5. Learning Outcome:
Learnt how to use of functions.
Learnt how to call a function in the main function.
Learnt the Linked List insertion and deletion.