Question: ructures and Introduction to Algorithms - All Define the SLL member function int speciaReplace(int v), which finds the last node whose value is even and

 ructures and Introduction to Algorithms - All Define the SLL member

ructures and Introduction to Algorithms - All Define the SLL member function int speciaReplace(int v), which finds the last node whose value is even and replaces the value in the node before it with v. If no value in the list is even, or if the only even value is in the first node, then the function does no replacement and returns -99. For example, if the list was [15, 24,9,32, 11), then after executing speciaReplacel 10), it will become (15,24,10,32,11), and the function returns 9. Also, if the list was [20,7,15,17], then after executing speciaReplace( 10), the list remains (20.7,15,17] and the function returns -99. Below is the SLLAPI you are allowed to use to solve this question: class SLLC private: Node" h;//stores the address of the first cell in the list Node* t;//stores the address of the last cell in the list public: l/constructors SLLO; --SLLO; I/Get Information bool isEmpty();//the list is empty iff both head and tail are equal to null void print();/eeds a loop from head to tail that prints all info inbetween int getHead();//retruns the address of the first node in the list int get Tail();//returns the address of the last node in the list Node' getHeadNode();//returns the address of the first node in the list Node get TailNode();//returns the address of the last node in the list

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!