Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#ifndef _LINKED_LIST #define _LINKED_LIST #include ListInterface.h #include Node.h #include PrecondViolatedExcep.h template class LinkedList : public ListInterface { private: Node * headPtr; // Pointer to first

#ifndef _LINKED_LIST

#define _LINKED_LIST

#include "ListInterface.h"

#include "Node.h"

#include "PrecondViolatedExcep.h"

template

class LinkedList : public ListInterface

{

private:

Node* headPtr; // Pointer to first node in the chain;

// (contains the first entry in the list)

int itemCount; // Current count of list items

// Locates a specified node in this linked list.

// @pre position is the number of the desired node;

// position >= 1 and position <= itemCount.

// @post The node is found and a pointer to it is returned.

// @param position The number of the node to locate.

// @return A pointer to the node at the given position.

Node* getNodeAt(int position) const;

public:

LinkedList();

LinkedList(const LinkedList& aList);

virtual ~LinkedList();

bool isEmpty() const;

int getLength() const;

bool insert(int newPosition, const ItemType& newEntry);

bool remove(int position);

void clear();

/** @throw PrecondViolatedExcep if position < 1 or

position > getLength(). */

ItemType getEntry(int position) const throw(PrecondViolatedExcep);

/** @throw PrecondViolatedExcep if position < 1 or

position > getLength(). */

void setEntry(int position, const ItemType& newEntry)

throw(PrecondViolatedExcep);

};

The following will need to be modified:

- LinkedList.h: add a new Node* called tailPtr which points to the last item in the list

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_2

Step: 3

blur-text-image_3

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

2. The conditions of my life are excellent.

Answered: 1 week ago

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago