Draw a sketch of a doubly-linked list specifically of class


You need help with these three questions. Please answer all of them

1. Draw a sketch of a doubly-linked list, specifically of class DLinkedList in DLinkedList.h, containing the first four words of your favorite song (one word in each node). Make sure to show the DLinkedList object, all node objects, and all objects' data members and pointers.

2. Complete the following main function to create your linked list above (Your code should go in only the indicated space - do not change any other code).

#include

#include

#include "DLinkedList.h"

using namespace std;

int main()

{

DLinkedList lyrics;

// YOUR CODE TO CREATE THE LIST GOES HERE

cout << lyrics.front() << endl;

}

3. Write the following new member function for the DLinkedList class. The member function must swap the first and second data nodes (not the sentinels) in the linked list (other data nodes stay as they are). Throw an exception if the list has fewer than two elements. Your code should go in only the indicated space (in DLinkedList.h) - do not change any other code.

template

void DLinkedList::swapFirstAndSecond(){

// YOUR CODE TO SWAP NODES GOES HERE

}

Test that your code works by again printing out the front of the list in your main function after calling lyrics.swapFirstAndSecond().

Include a screen capture of the output of your program

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Draw a sketch of a doubly-linked list specifically of class
Reference No:- TGS02873499

Expected delivery within 24 Hours