Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ only: For this assignment you will build a doubly linked list class. The name of your class is dList, and each entry in the

C++ only:

For this assignment you will build a doubly linked list class. The name of your class is dList, and each entry in the linked list should store 2 different values, a key (integer) and a type (character). A struct (or class) defining the nodes of the linked list should appear outside of the dList class definition and should be named node. The class should support the following operations:

image text in transcribedYou should be careful to manage your memory and implement a destructor, but it is not required to implement a copy constructor or assignment operator for the class. You may use dummy header and tail nodes if you want. Your code should be in a file named dList.cpp and the sample main below should compile and work without modification. You are not allowed any include files in dList.cpp, notice that the main function will include iostream before the dList.cpp file.

MAIN:

#include using namespace std; #include "dList.cpp" #define SMALL 200 #define MAX 100000 #define ROUNDS 100 int main(){ int i, x[MAX]; char ch[MAX]; for(i=0;i dList A(x,ch,SMALL), B; A.out(10); node *tmp = A.search(2*SMALL-8); A.moveFront(tmp); A.out(10); A.moveBack(tmp); A.out(10); A.find('b'); A.sort(); A.out(10); A.out(10,'b'); A.addBack(500,'d'); A.addFront(501,'z'); A.out(10); A.out(10,'b'); B.addFront(1,'a'); B.addBack(2,'b'); B.out(2); for(int j=0; j cout dList() dList(int[], char[l,int) Default constructor. Should create an empty list. Constructor where the first two parameters are arrays and the third is the length of the arrays. The constructor should initialize the list with the contents of the arravs. void addFront(int, char)Creates a new node at the front of the list. void addBack(int, char)Creates a new node at the back of the list. node *search(int) Searches the list for the occurrence of the int parameter in the list and returns a pointer to the node containing that key. Outputs all keys that have the type equal to the character parameter. Should start at the front of the list and output the keys in list order. void find(char) void moveFront(node *) Moves the node pointed to by the parameter to the front of the void moveBack(node*)Moves the node pointed to by the parameter to the back of the void out(int, char = ) | Outputs the first k elements of the list, where k is the int list. list. parameter. The char parameter can be either 'f, or 'bT is the default value. If the char is the output starts at the front of the list. If the char is 'b', start at the end of the list and work backwards. Should perform a O(n lg n) time sorting algorithm on the items in the list. The list should be in increasing order based on the integer key after this operation. void sort() dList() dList(int[], char[l,int) Default constructor. Should create an empty list. Constructor where the first two parameters are arrays and the third is the length of the arrays. The constructor should initialize the list with the contents of the arravs. void addFront(int, char)Creates a new node at the front of the list. void addBack(int, char)Creates a new node at the back of the list. node *search(int) Searches the list for the occurrence of the int parameter in the list and returns a pointer to the node containing that key. Outputs all keys that have the type equal to the character parameter. Should start at the front of the list and output the keys in list order. void find(char) void moveFront(node *) Moves the node pointed to by the parameter to the front of the void moveBack(node*)Moves the node pointed to by the parameter to the back of the void out(int, char = ) | Outputs the first k elements of the list, where k is the int list. list. parameter. The char parameter can be either 'f, or 'bT is the default value. If the char is the output starts at the front of the list. If the char is 'b', start at the end of the list and work backwards. Should perform a O(n lg n) time sorting algorithm on the items in the list. The list should be in increasing order based on the integer key after this operation. void sort()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions