Question: Using C++ Given the definition for a node in a linked list, struct node { int data; node *next; }; Use this prototype node* acs_sublist(node

Using C++

Given the definition for a node in a linked list,

struct node {

int data;

node *next;

};

Use this prototype

node* acs_sublist(node *p)

to write a function that will remove nodes for the list. It should remove all nodes that are not larger in values than all nodes that came before it.

  • acs_sublist must be a destructive function meaning that no new nodes are allocated and the original list p cannot be reconstructed.

Your solution needs to recursive.

Examples

if p points to the linked list [ 1 5 3 4 7 3 4 1 11 12 13 2 100 1] then p should be [ 1 5 7 11 12 13 100] .

if p points to the linked list [ 6 14 18 ] then p should be [ 6 14 18] .

if p points to the linked list [ 10 1 2 3 4 5 6 7 ] then p should be [ 10] .

Should be call like this

h = acs_sublist(h)

Do not use arrays. Do not use vectors. Do not strings. Do not use globals. Do not use static variables. Do not use the STL.

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!