Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Define the SLL member function int speciaDecrement(int v), which finds the last node whose value is a multiple of 5 and replaces the value

image text in transcribedc++

Define the SLL member function int speciaDecrement(int v), which finds the last node whose value is a multiple of 5 and replaces the value in the node before it with v. If no value in the list is a multiple of 5, or if the only multiple of 5 is value is in the first node, then the function does no decrement and returns -77. For example, if the list was [15, 24, 9, 30, 11], then after executing speciaDecrement( 4), it will become [15, 24,5,30,11), and the function returns 9. Also, if the list was [20,7,54,17], then after executing speciaDecrement( 4), the list remains [20,7,54,17] and the function returns -77. 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: //constructors SLL(); SLL(); //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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions