Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 speciaReplace( 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 speciaReplacel 10), the list remains [20,7,15,17] and the function returns -99. Below is the SLL API you are allowed to use to solve this question: class SLLE 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: Il constructors SLLO; -SLL(); 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 getTail();//returns the address of the last node in the list Node"getHeadNode();//returns the address of the first node in the list Node.getTailNode();//returns the address of the last node in the list }

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_2

Step: 3

blur-text-image_3

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Does it make clear how measurements are defined?

Answered: 1 week ago

Question

Define and measure service productivity.

Answered: 1 week ago