Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using c++ , screenshot of display output as well. Preferably using visual studio

ID: 3709328 • Letter: U

Question

Using c++ , screenshot of display output as well. Preferably using visual studio. The output is Random I believe doesn’t have to be the same,

Attached is the input a & b txt file as well.

Question -1: input_a.txt is provided on Blackboard to populate the linked list. Write a function in C++ program that will take the head of the linked list and remove the duplicate values from the list. Perform operations on a singly linked list. CAWINDOWSlsystem321cmd.exe Linked list before removing duplicates 10 20 10 20 30 15 25 35 45 55 Linked list after removing duplicates 10 20 30 15 25 35 45 55 Press any key to continue.. . Question -2: input_b.txt is provided on Blackboard to populate two linked lists. Write a function in C++ program that will create another linked list with the intersected values from those two lists. Perform operations on a singly linked list. Linked list1: ??? ?? 4e se 60 70 80 90 100 inked list2: 11 22 33 40 51 60 7e 80 91 99 Intersected linked list: 70 60 40 ress any key to continue..

Explanation / Answer

Remove duplicates in c++
#include<bits/stdc++.h>
using namespace std;
struct Node
{
int data;
struct Node *next;
};
struct Node *newNode(int data)
{
Node *temp = new Node;
temp->data = data;
temp->next = NULL;
return temp;
}
void removeDuplicates(struct Node *start)
{
struct Node *ptr1, *ptr2, *dup;
ptr1 = start;
while (ptr1 != NULL && ptr1->next != NULL)
{
ptr2 = ptr1;
while (ptr2->next != NULL)
{
if (ptr1->data == ptr2->next->data)
{
dup = ptr2->next;
ptr2->next = ptr2->next->next;
delete(dup);
}
else
ptr2 = ptr2->next;
}
ptr1 = ptr1->next;
}
}
void printList(struct Node *node)
{
while (node != NULL)
{
printf("%d ", node->data);
node = node->next;
}
}
int main()
{
struct Node *start = newNode(10);
start->next = newNode(12);
start->next->next = newNode(11);
start->next->next->next = newNode(11);
start->next->next->next->next = newNode(12);
start->next->next->next->next->next =
newNode(11);
start->next->next->next->next->next->next =
newNode(10);
printf("Linked list before removing duplicates ");
printList(start);
removeDuplicates(start);
printf(" Linked list after removing duplicates ");
printList(start);
return 0;
}
Intersection set of two linked list in c++

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
struct Node
{
int data;
struct Node* next;
};

void push(struct Node** head_ref, int new_data);
bool isPresent(struct Node *head, int data);
struct Node *getIntersection(struct Node *head1,
struct Node *head2)
{
struct Node *result = NULL;
struct Node *t1 = head1;
while (t1 != NULL)
{
if (isPresent(head2, t1->data))
push (&result, t1->data);
t1 = t1->next;
}
return result;
}
void push (struct Node** head_ref, int new_data)
{
struct Node* new_node =
(struct Node*) malloc(sizeof(struct Node));
new_node->data = new_data;
new_node->next = (*head_ref);
(*head_ref) = new_node;
}
void printList (struct Node *node)
{
while (node != NULL)
{
printf ("%d ", node->data);
node = node->next;
}
}

bool isPresent (struct Node *head, int data)
{
struct Node *t = head;
while (t != NULL)
{
if (t->data == data)
return 1;
t = t->next;
}
return 0;
}
int main()
{
struct Node* head1 = NULL;
struct Node* head2 = NULL;
struct Node* intersecn = NULL;
struct Node* unin = NULL;
push (&head1, 20);
push (&head1, 4);
push (&head1, 15);
push (&head1, 10);
push (&head2, 10);
push (&head2, 2);
push (&head2, 4);
push (&head2, 8);
intersecn = getIntersection (head1, head2);

printf (" First list is ");
printList (head1);
printf (" Second list is ");
printList (head2);
printf (" Intersection list is ");
printList (intersecn);
return 0;
}
Note : copy the cpp files and run on complier you will find output

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote