Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedDoubly 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; ListNode* cursor;

};

#endif

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago