Write a recursive function in split.cpp to split the elements of a sorted (in increasing…
Jump to turn (6)
- 1Write a recursive function in split.cpp to split the elements of a sorted (in in
- 2make the code less efficient so it look like a college student's work
- 3why do i get error: use of undeclared identifier 'nullptr'
- 4Node list = new Node(1, new Node(2, new Node(3, new Node(4, new Node(5))))); cha
- 5when i use Node list = new Node(1, new Node(2, new Node(3, new Node(4, new Node(
- 6my default construtor must be Node(int v, Node n ) : value(v), next(n) { } }; me
- User
Write a recursive function in split.cpp to split the elements of a sorted (in increasing order), singly-linked lists of integers into two sorted, singly-linked lists, where the first list contains all items with an odd value, and the second list contains all items with an even value. The original list should not be preserved and Your function must be recursive . When your split function terminates, in should be set to NULL (the original list is not preserved), odds should point to the head of a linked list containing all items where value is an odd integer, and evens should point to the head of a linked list containing all items where value is an even integer.
Hint: by far the easiest way to make this work is to not delete or new nodes, but just to change the pointers.
i have already implemented the node type for the function below: struct Node { int value; Node* next;
/**
- Initializing constructor / Node(int v, Node n) { value = v; next = n; } };
finally, the function you should implement is void split (Node*& in, Node*& odds, Node*& evens);
- Assistant