Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need some help Hinclude iostrean sinclude sstrings using nasespace std; If Implement the Studentlist data structure with a doubly linked 11 st implementation. class student
need some help
Hinclude iostrean sinclude sstrings using nasespace std; If Implement the "Studentlist" data structure with a doubly linked 11 st implementation. class student I public: string nanes int ids float 6PA; Student(string inNene = "nobody", int InId =1, float inGPA =0.0){ nane = inkenes 1d= intd GPA=inGPA; 33 class Mode \{ public: Student data; Mode "next; Node "prev; Mode (Student x, Mode "nextptr = nullptr, Node "prevPtr = nullptr) i data =x; next = nextPtr; prev = prevptry 3; class studentList f private: Node thead; Minclude "StudentList. h" 11 Define a constructor to Inftialize the 1 st. The list starts with no StudentLlstistudentList() ( nustudents=8 3 If return the number of students currently in the 14 st int Studentist:t Hststze() \{ return numstudente: I/add a Node with a student to the front (head) of the 11st. void Studentlist: taddfront(Student s) f If (head t nullptr) f Node * newlode = new Node (s) s head next = newlodes head = newiode; itnustudents; 3 elset Mode " newlode = nev Node (s); head = newtode; tail = newlodes Hnustudents; 3 ] Iladd . Node ifth a student to the back (tafl) of the Hist. vold StudentLIst: addasck(Student s) f 1f(tad1.1=nallptr){ Mode " neudbde = now Node(s); tadi next = newode; tatl = newodes inunstudents; ] elsef Mode " newbole = new Node (s)] head = newlodej tad1 = newoder Hnustudents; di l/Print out the nemes of each student in the 1 stst. vold Studenttisti1printist() ( Node * newiode = nei Mode (s); I/ while pointer is not nullpter whille() 3. If Renove the tode with the student at the back (tail) of the list If should not fall if 1ist is eapty! Print an error message if thts occurs I/ Don"t forget that your head and tall polnters mill be null polnters 1f, t vold studentListi tpopeack() ( ) thistepp 1/ Remove the Mode with the student at the front (head) of the 1 ist II should not fail if 11 st is enptyl Print an error nessage if this occurs /1 Don't forget that your head and tail polnters will be nul1 pointers if the list is enpty void studentist:tpopfront() \{ 3 // Insert a student at the position "Index" . If for this 1ist, count head as Index If if index is outside of current list range, 11 print a message and insert the student at the back of the Hist If the prevlous Mode at your target Index should be moved formard. I/"For exanpe, Node with student at Index 1 , becomes index 1+1 * If Remember that you already have methods that can add students // to the front or back of 1 ist if needed I Don't repeat this code. void StudentListt: insertstudent (5tudent 5, int index) \{ 3 I/find the student with the given id number and return thee If If no student matches, print a nessage If and create and return a dumy student object Student studentList: iretrievestudent(lint Idian) f student fixthis; return flacthis, I/ Renove a Node with a student from the 11 st with a given id number If If no student matches, print a message and do nothing void Studentlistt trenovestudentbyId (int idilun) \{\} I/Change the gpa of the student udth given id number to newepA void Studentlist: tupdatecPA(lnt lawe, floot newGPA) \{f flAdd all students froa otherlist to this Hst. flotherlist should be eapty after this operation. f1 For exanple, If the 14 st has 3 students: st s2Step 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