Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Help in modifying function to update nodes Problem: Help needed to allow the findDupe() function to update a node with the information found in

C++ Help in modifying function to update nodes

Problem: Help needed to allow the findDupe() function to update a node with the information found in the duplicate node.

Input File:

image text in transcribed

My output AFTER Sorting:

image text in transcribed

Expected output AFTER Sorting:

image text in transcribed

My function to find duplicates, right now, it simply removes records that have the same id. Not sure how to make it use updated information

image text in transcribed

NOTE: There are 3 records in the input file with the same id. If a record has the exact same information as a previous record, it is recognized as a duplicate and deleted. If it has the same id but with different information, in this case, the DOB is different, the node is updated with the new info.

{id: 1234567, first: Mary, last: Green, DOB: 1996-10-03,GPA:4.0) {id: 1234568, first:Peter, last: White, DOB: 1997-05-22, GPA:3.8} {id: 1654238, first: Nick, last:Park, DOB: 1995-08-18,GPA: 4.0} {id: 1234587, first:Katy, last: Green, DOB: 1995-08-18, GPA: 4.0} {id: 1654238, first:Nick, last:Park,DOB: 1995-08-18, GPA:4.0) {id: 1654238, first:Nick, last:Park,DOB: 1995-08-28, GPA: 4.0} Kid: 1234567, first:Mary, last: Green, DOB: 1996-10-03,GPA: 4.0} {id: 1234568, first: Peter, last: White, DOB: 1997-05-22, GPA: 3.8) {id: 1234587, first:Katy, last: Green, DOB: 1995-08-18, GPA: 4.0) {id: 1654238, first: Nick, last:Park, DOB: 1995-08-18, GPA:4.0} Kid: 1234567, first: Mary, last: Green, DOB: 1996-10-03,GPA:4.0) {id: 1234568, first:Peter, last: White, DOB: 1997-05-22, GPA:3.8} {id: 1234587, first:Katy, last: Green, DOB: 1995-08-18, GPA: 4.0} {id: 1654238, first:Nick, last:Park,DOB: 1995-08-28, GPA:4.0) void Linkedlist::findDupe() { //implement //cout set; unordered_set setter; while (curr != nullptr) { if (setter.find(curr->id) != setter.end()) { prev->next = curr->next; delete curr; else { setter.insert(curr->id); prev = curry curr = prev->next; {id: 1234567, first: Mary, last: Green, DOB: 1996-10-03,GPA:4.0) {id: 1234568, first:Peter, last: White, DOB: 1997-05-22, GPA:3.8} {id: 1654238, first: Nick, last:Park, DOB: 1995-08-18,GPA: 4.0} {id: 1234587, first:Katy, last: Green, DOB: 1995-08-18, GPA: 4.0} {id: 1654238, first:Nick, last:Park,DOB: 1995-08-18, GPA:4.0) {id: 1654238, first:Nick, last:Park,DOB: 1995-08-28, GPA: 4.0} Kid: 1234567, first:Mary, last: Green, DOB: 1996-10-03,GPA: 4.0} {id: 1234568, first: Peter, last: White, DOB: 1997-05-22, GPA: 3.8) {id: 1234587, first:Katy, last: Green, DOB: 1995-08-18, GPA: 4.0) {id: 1654238, first: Nick, last:Park, DOB: 1995-08-18, GPA:4.0} Kid: 1234567, first: Mary, last: Green, DOB: 1996-10-03,GPA:4.0) {id: 1234568, first:Peter, last: White, DOB: 1997-05-22, GPA:3.8} {id: 1234587, first:Katy, last: Green, DOB: 1995-08-18, GPA: 4.0} {id: 1654238, first:Nick, last:Park,DOB: 1995-08-28, GPA:4.0) void Linkedlist::findDupe() { //implement //cout set; unordered_set setter; while (curr != nullptr) { if (setter.find(curr->id) != setter.end()) { prev->next = curr->next; delete curr; else { setter.insert(curr->id); prev = curry curr = prev->next

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions