C++ DOUBLY LINKED LIST: Implement the remove_between function for my code: Incomplete code: #include #include using namespace std; class DoublyLinkedList : public List { node* head; node* tail; int index; node* create_node(int num, node* predecessor, node* successor) { node* n = (node*) malloc( sizeof(node) ); n->element = num; n->next = successor; n->prev = predecessor; return n; } void add_between(int num, node* predecessor, node* successor) { node* newest = create_node(num, predecessor, successor); predecessor->next = newest; successor->prev = newest; index++; } void remove_between(int num, node* predecessor, node* successor) { ///// CODE HERE }
C++ DOUBLY LINKED LIST:
Implement the remove_between function for my code:
Incomplete code:
#include <cstdlib>
#include <iostream>
using namespace std;
class DoublyLinkedList : public List {
node* head;
node* tail;
int index;
node* create_node(int num, node* predecessor, node* successor) {
node* n = (node*) malloc( sizeof(node) );
n->element = num;
n->next = successor;
n->prev = predecessor;
return n;
}
void add_between(int num, node* predecessor, node* successor) {
node* newest = create_node(num, predecessor, successor);
predecessor->next = newest;
successor->prev = newest;
index++;
}
void remove_between(int num, node* predecessor, node* successor) {
///// CODE HERE
}
Step by step
Solved in 2 steps with 1 images