Question: complete the missing code Hinclude prev - nullptr; } }; class DoublyLinkedList { public: DoublyLinkedListNode *head; DoublyLinkedListNode *tail; DoublyLinkedList() i this->head - nullptr; this tail

complete the missing code Hinclude prev - nullptr; \} \}; class DoublyLinkedList\{ public: DoublyLinkedListNode *head; DoublyLinkedListNode *tail; DoublyLinkedList() i this->head - nullptr; thistail - nullptr; \} void insert_node(int node_data) i DoublyLinkedListNode* node - newDoublyLinkedListNode(node_data); if (!this-shead) i this->head - node; f else i this tail->next

complete the missing code

Hinclude prev - nullptr; \} \}; class DoublyLinkedList \{ public: DoublyLinkedListNode *head; DoublyLinkedListNode *tail; DoublyLinkedList() i this->head - nullptr; this tail - nullptr; \} void insert_node(int node_data) i DoublyLinkedListNode* node - new DoublyLinkedListNode(node_data); if (!this-shead) i this->head - node; f else i this tail->next - node; node->prev - this->tail; \} this->tail - node; \} \} void print_doubly_linked_List(DoublyLinkedListNode* node, string sep, ofstreamz fout) \{ while (node) \{ fout data; node - node->next; if (node) \{ fout next; /* * Complete the 'reverse' function below. * * The function is expected to return an INTEGER_DOUBLY_LINKED_LIST. * The function accepts INTEGER_DOUBLY_LINKED_LIST llist as parameter. / / * For your reference: * DoublyLinkedListNode \{ * int data; * DoublyLinkedListNode* next; * DoublyLinkedListNode* prev; }; * / DoublyLinkedListNode* reverse(DoublyLinkedListNode* llist) \{ int main() \{ ofstream fout(getenv("OUTPUT_PATH")); int t; cin t; cin.ignore(numeric_limitsmax(), ); for (int titr=0;titr llist_count; cin.ignore(numeric_limitsmax(), ); for (int i=0;iinsert_node(llist_item); \} DoublyLinkedListNode llistl = reverse (llist > head ); print_doubly_linked_list(llist1, " ", fout); fout " "; free_doubly_linked_list(llist1); out.close (); eturn 0 ; Return a reference to the head node of the reversed list. Note: The head node might be NULL to indicate that the list is empty. Function Description Complete the reverse function in the editor below. reverse has the following parameter(s): - DoublyLinkedListNode head: a reference to the head of a DoublylinkedList Returns - DoublylinkedListNode: a reference to the head of the reversed list Input Format The first line contains an integer t, the number of test cases. Each test case is of the following format: - The first line contains an integer n, the number of elements in the linked list. - The next n lines contain an integer each denoting an element of the linked list. Constraints - 1

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!