Question: 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:

C++ Help in modifying function to update nodes Problem: Help needed to

My output AFTER Sorting:

allow the findDupe() function to update a node with the information found

Expected output AFTER Sorting:

in the duplicate node. Input File: My output AFTER Sorting: Expected output

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

AFTER Sorting: My function to find duplicates, right now, it simply removes

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!