Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data Structures in C++ implement code using a doubly-linked list class. In this program I should fix a incompleted header file containing doubly-linked list class

Data Structures in C++ implement code using a doubly-linked list class.

In this program I should fix a incompleted header file containing doubly-linked list class ( can be anything)

and a source file which contains a main function that tests the implementation of the list class.

Following is the original prompt for the program:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

And here's the incompleted header file that needs to be implemented

-----------------------------------------------

#pragma once /* dlist.h Doubly-linked lists of ints */ #include  class dlist { public: dlist() { } // Implement the destructor, to delete all the nodes ~dlist(); struct node { int value; node* next; node* prev; }; node* head() const { return _head; } node* tail() const { return _tail; } // **** Implement ALL the following methods **** // Returns the node at a particular index (0 is the head). node* at(int); // Insert a new value, after an existing one void insert(node *previous, int value); // Delete the given node void del(node* which); // Add a new element to the *end* of the list void push_back(int value); // Add a new element to the *beginning* of the list void push_front(int value); // Remove the first element void pop_front(); // Remove the last element void pop_back(); // Get the size of the list int size(); // Returns true if the list is empty (size == 0) bool empty(); private: node* _head = nullptr; node* _tail = nullptr; }; // **** Implement ALL the following functions **** /* out  

-----------------------------------------------------

After implementing the header file please make a simple main function to test the implementation

Please put the source file (containing main function) in the bottom so I can separate them in a source file later.

Thank you in advance!

In this assignment, you will implement a doubly-linked list class, together with some list operations. To make things easier, you'll implement a list of int, rather than a template class. lpragma once dlist.h Doubly-linked lists of ints include Kostream class dlist public: dlist struct node int value node next node prev node* head() const f return -head; h node* tail() const return -tail; Implement ALL the following methods Returns the node at a particular index (0 is the head node at(int) Insert a new value, after an existing one void insert (node *previous, int value) In this assignment, you will implement a doubly-linked list class, together with some list operations. To make things easier, you'll implement a list of int, rather than a template class. lpragma once dlist.h Doubly-linked lists of ints include Kostream class dlist public: dlist struct node int value node next node prev node* head() const f return -head; h node* tail() const return -tail; Implement ALL the following methods Returns the node at a particular index (0 is the head node at(int) Insert a new value, after an existing one void insert (node *previous, int value)

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

LO5 Highlight five external recruiting sources.

Answered: 1 week ago