Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Please Implement the LinkedList class as described in the following header file: include Node.h #include using namespace std class LinkedList public: typedef Node: :value

C++ Pleaseimage text in transcribedimage text in transcribedimage text in transcribed

Implement the LinkedList class as described in the following header file: include "Node.h" #include using namespace std class LinkedList public: typedef Node: :value type data type typedef size t size type /7 Constructor creates an empty list LinkedListO Summary:Constructor creates a linked list object with count set at 0 // Accessor functions for the list's head ptr Node getHeadPtr Summary:Returns a pointer to the head Node of the list / Preconditions: The list has been initialized. / Postconditions: A pointer to the head has been returned. const Node getHeadPtr Oconst Summary: Returns a pointer to the head Node of the list. /Preconditions: The list has been initialized. // Postconditions: A pointer to the head has been returned Accessor functions for the 1ist's tail ptr Node* getTailPtr const Node getTailPtr )const 7Summary: Returns a pointer to the end Node of the list. /Preconditions: The list has been initialized. /7 Postconditions: A pointer to the end of the list has been returned. size type 1ist length0 const Summary: This function returns the number of Nodes in the list Preconditions: A list exists 7Postconditions: Returns0 if list is empty, otherwise it returns the number of // items in the list, i.e. count bool isEmpty) const Summary: This function returns true if the list is empty / Preconditions: A list object exists //Postconditions: Returns true if the list contains no Nodes and false if the list // contains at least one Node void head insert (const Node: value type& value) Summary: This function inserts a new Node at the beginning of the list // Preconditions: A head ptr exists and a new value has been passed in. / Postconditions: A new Node has been added to the beginning of the list with the //value in the data field at the head of the list void list insert (Node prev ptr, const Node:value type& value) Summary: This function inserts a new Node with value in the data field after the 7 prev_ptr Node // Preconditions: prev ptr is a pointer to the Node that is before the the spot // where we want to insert a new Node with data equal to value / Postconditions: The list with one more Node that contains the value passed into the function Node list_ search (const Node::value_ type& target) Summary: This function looks for the Node that has the target value in the data // field 7 Preconditions: head_ptr points to the beginning of the list. target is the data // we are looking for 7Postconditions: A pointer to the Node containing the target is returned or NULL // is returned if the target was not in the list const Node list_search (const Node::value_type&target)const Summary: This function looks for the Node that has the target value in the data // field /Preconditions: head ptr points to the beginning of the list. target is the data // we are looking for. /Postconditions: A pointer to the Node containing the target is returned or NULL /lis returned if the target was not in the list. private: Node* head ptr 1/ Points to front of list Node* tail ptr // Points to end of list size type node count// holds the number of Nodes in the list void list_copy (const LinkedList&source list, LinkedList&destination list class Node public: I TYPEDEF typedef double value_type; // CONSTRUCTOR Node(const value, type& init-data-value-type ( ), Node* init-link = NULL) data_field -init_data; link_field -init_link; //Member functions to set the data and link fields: void set_data(const value_type& new_data) data_fieldnew_data; h void set_link (Node* new_link) link_fieldnew_link; h //Constant member function to retrieve the current data: value_type data) const return data_field; // Two slightly different member functions to retrieve the current link: const Node* link) const return link_field; // returns pointer to a const type Nodex link) return link_field;h private: value_type data_field; Node* link_field; hi #endif /* Node-h */

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 Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

1. What might have led to the misinformation?

Answered: 1 week ago