Doubly Linked List is a data structure that holds a list of items with double links: previous and next. In this homework, you need to implement all functions in the defined ListLinked class (prototype is provided by the instructor). Please download the header file (ListLinked.h) from ecourses, read the comments and complete them using C++. You need to implement all of the ListLinked ADT functions in ListLinked.cpp file, and test them in main.cpp. //-------------------------------------------------------------------- // // Homework 3                                          ListLinked.h // // Class declaration for the Doubly linked implementation of the List ADT // //-------------------------------------------------------------------- #ifndef LISTLINKED_H #define LISTLINKED_H #include using namespace std; template class ListNode { // doubly linked list node public:    ListNode(const DataType& nodeData, ListNode* nextPtr, ListNode* prevPtr);    DataType dataItem;    ListNode* next;    ListNode* prev; }; template class List { // a list implemented using doubly linked nodes public:    List();    List(const List& other); // copy constructor    List& operator=(const List& other); // assignment operator    ~List();    void insert(const DataType& newDataItem); // insert an item after cursor    void remove(); // remove the cursor node, and move the cursor to the next node. If the removed node is the last node, move the cursor to the beginning of the list    void replace(const DataType& newDataItem); // replace the cursor node value    void clear(); // clear the list, remove all nodes    bool isEmpty() const;    bool isFull() const;    void gotoBeginning(); // move cursor to the beginning of the list    void gotoEnd(); // move cursor to the end of the list    bool gotoNext(); // move cursor to the next node, return false if no next node is available    bool gotoPrior(); // move cursor to the prior node, return false if no prior node is available    DataType getCursor() const; // return the value of the cursor node    void moveToBeginning();   // move the cursor node to the beginning of the list    void insertBefore(const DataType& newDataItem); // insert a new item before the cursor    void print() const; // print the list, mark the cursor node private: // Do not change them for this homework    ListNode* head;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Doubly Linked List is a data structure that holds a list of items with double links: previous and next. In this homework, you need to implement all functions in the defined ListLinked class (prototype is provided by the instructor). Please download the header file (ListLinked.h) from ecourses, read the comments and complete them using C++. You need to implement all of the ListLinked ADT functions in ListLinked.cpp file, and test them in main.cpp.

//--------------------------------------------------------------------
//
// Homework 3                                          ListLinked.h
//
// Class declaration for the Doubly linked implementation of the List ADT
//
//--------------------------------------------------------------------

#ifndef LISTLINKED_H
#define LISTLINKED_H

#include <iostream>

using namespace std;

template <typename DataType>
class ListNode { // doubly linked list node
public:
   ListNode(const DataType& nodeData, ListNode* nextPtr, ListNode* prevPtr);

   DataType dataItem;
   ListNode* next;
   ListNode* prev;
};

template <typename DataType>
class List { // a list implemented using doubly linked nodes
public:
   List();
   List(const List& other); // copy constructor
   List& operator=(const List& other); // assignment operator
   ~List();

   void insert(const DataType& newDataItem); // insert an item after cursor
   void remove(); // remove the cursor node, and move the cursor to the next node. If the removed node is the last node, move the cursor to the beginning of the list
   void replace(const DataType& newDataItem); // replace the cursor node value
   void clear(); // clear the list, remove all nodes

   bool isEmpty() const;
   bool isFull() const;

   void gotoBeginning(); // move cursor to the beginning of the list
   void gotoEnd(); // move cursor to the end of the list
   bool gotoNext(); // move cursor to the next node, return false if no next node is available
   bool gotoPrior(); // move cursor to the prior node, return false if no prior node is available

   DataType getCursor() const; // return the value of the cursor node

   void moveToBeginning();   // move the cursor node to the beginning of the list

   void insertBefore(const DataType& newDataItem); // insert a new item before the cursor

   void print() const; // print the list, mark the cursor node

private: // Do not change them for this homework
   ListNode<DataType>* head;
   ListNode<DataType>* cursor;

};

#endif

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education