Question
Programming and data science Please try and help me with these steps or at least help explain where to start. Question: You will write a
Programming and data science
Please try and help me with these steps or at least help explain where to start.
Question: You will write a C++ program to load records in a plain text file to a doubly linked list, then copy the records to a dynamic array and delete the list. Then sort the records by specific attributes in alphabetical order, and output to a plain text file.
Each record is in one line (ends in ) without any spaces. Each attribute in one record is separated by , and consists of key and value (separated by :). I have been given following input file:
1)
{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}
And the following attributes:
1) Sort by first name
2) Sort by GPA, then ID
3) & 4) Sort by DOB, then GPA, then last name
5) Sort by: a g b c d
Specification: The main program should be called sort. Call syntax is as follows: ./sort input=input1.txt attributes=attributes1.txt output=output1.txt sort=
Notice that the file name will not necessarily be the same every time. Therefore, your program will have to take that into account. Example: ./sort input=in1.txt attributes=att1.txt output=out1.txt sort=quick
The following images show an example:
input.txt --------------- H | {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:12345 Green, DOB:1995-08-18 , GPA:4.0} t t- | H H 1 0 0 | | + + | .. - - K - e a - - 4 - - - | | | | attributes1.txt (sort by -------- first 1 1 H | F. | R | 0 E ---- attributes2.txt (sort by GPA and id. First compare GPA, then id) --------- GPA id attributes3.txt (sort by DOB, GPA and last) DOB GPA last - output1.txt (sort by first) {id:1234587, first: Katy, last:Green, DOB:1995-08-18, GPA:4.0} {id:1234567, first: Mary, last:Green, DOB:1996-10-03, GPA:4.0} {id:1654238, first:Nick, last:Park, DOB:1995-08-18, GPA: 4.0} input.txt --------------- H | {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:12345 Green, DOB:1995-08-18 , GPA:4.0} t t- | H H 1 0 0 | | + + | .. - - K - e a - - 4 - - - | | | | attributes1.txt (sort by -------- first 1 1 H | F. | R | 0 E ---- attributes2.txt (sort by GPA and id. First compare GPA, then id) --------- GPA id attributes3.txt (sort by DOB, GPA and last) DOB GPA last - output1.txt (sort by first) {id:1234587, first: Katy, last:Green, DOB:1995-08-18, GPA:4.0} {id:1234567, first: Mary, last:Green, DOB:1996-10-03, GPA:4.0} {id:1654238, first:Nick, last:Park, DOB:1995-08-18, GPA: 4.0}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started