Advanced Programming Lab 1.3
Advanced Programming Lab 1.3
Experiment 1.3
Student Name: Sahil Shreyansh UID: 21BCS8687
Branch: CSE Section/Group: 638 B
Semester: 5 Date of Performance:05/09/23
Subject Name: Advance Programming Lab-1 Subject Code: 21CSP-314
1. Aim:
To understand and implement the concept of a linked list
2. Objective:
1. To compare two linked lists and check if they are equal.
2. Determine the optimal starting point for a truck's journey along a
circular route with multiple petrol pumps.
class SinglyLinkedListNode {
public:
int data;
SinglyLinkedListNode *next;
SinglyLinkedListNode(int node_data) {
this->data = node_data;
this->next = nullptr;
}
};
class SinglyLinkedList {
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
if (!this->head) {
this->head = node;
} else {
this->tail->next = node;
}
this->tail = node;
}
};
node = node->next;
if (node) {
fout << sep;
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
}
}
}
free(temp);
}
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
int tests;
cin >> tests;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
int llist1_count;
cin >> llist1_count;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
llist1->insert_node(llist1_item);
}
int llist2_count;
cin >> llist2_count;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
llist2->insert_node(llist2_item);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
fout.close();
return 0;
}
2.#include <bits/stdc++.h>
class SinglyLinkedListNode {
public:
int data;
SinglyLinkedListNode *next;
SinglyLinkedListNode(int node_data) {
this->data = node_data;
this->next = nullptr;
}
};
class SinglyLinkedList {
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
if (!this->head) {
this->head = node;
} else {
this->tail->next = node;
}
this->tail = node;
}
};
node = node->next;
if (node) {
fout << sep;
}
}
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
free(temp);
}
}
}
return false;
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int tests;
cin >> tests;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
int llist_count;
cin >> llist_count;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
llist->insert_node(llist_item);
}
extra = temp;
}
if (i != llist_count-1) {
temp = temp->next;
}
}
temp->next = extra;
fout.close();
return 0;
}
Output:
1.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
2.