Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

class linkedListType { public: linkedListType(); void removeFromFront(); //Removing the node from the head of the linked list void removeAfterMe(nodeType * afterMePtr); //Remove the Node after

image text in transcribed

class linkedListType { public:

linkedListType(); void removeFromFront(); //Removing the node from the head of the linked list

void removeAfterMe(nodeType * afterMePtr); //Remove the Node after a Given Node from a Linked List

void insertAtFront(int dataVal); //Insert a Node at the Front of a Linked List

void insertAfterMe(nodeType *afterMePtr, int dataVal); //Insert a Node after a Given Node in a Linked List

void printList(ostream &outs); //Output the Data Parts of the Nodes of a Linked List(List Traversal)

void destroyList(); //Destroy a Linked List

void appendNode(int dataVal); //Append a Node to a Linked List

nodeType * searchValue(int target); //Searching a Linked List for a node with target value returns a pointer to the first found node with the target

//default constructor. Initializes the list to an empty state. Postcondition: first = NULL, last = NULL, count = 0;

linkedListType(const linkedListType& otherList); //copy constructor

~linkedListType(); //Destructor. Deletes all the nodes from the list. Postcondition: The list object is destroyed.

void LinkedListType::duplicateRange (int low, int up);

void LinkedListType::removeEven ();

void LinkedListType::removeFirstN (int N);

void LinkedListType::removeLastN (int N);

void LinkedListType::subtractNodes (LinkedListType & anotherList);

protected: int count; //variable to store the number of list elements nodeType *head; //pointer to the first node of the list

private:

};

Write the functions listed below for the LinkedListType class. DO NOT MAKE ANY CHANGES TO EXISTING CODE UNLESS THERE ARE SYNTAX ERRORS. void LinkedListType::duplicateRange (int low, int up); While traversing the given linked list, if you encounter a node whose int value, x, where low 26 -> 77-> 12-> 33, then the updated linked list should contain 23 -> 26-> 26-> 77 -> 12 -> 33 -> 33. If the linked list is empty, then no action is taken. void LinkedListType.removeEven(); While traversing the given linked list, if you encounter a node whose int value, x, is an even number, then remove that node. For example, for the given list 23 -> 26-> 77 -> 12-> 33, then the updated linked list should contain 23 -> 77-> 33. If the linked list is empty, then no action is taken. void LinkedListType::removeFirstN (int N); Remove the first N nodes from the linked list N>= 1 should be checked. If N> number-of-nodes, then the resulting list will be empty. Your code should Not traverse the linked list more than 1 time. void LinkedListType::removeLastN (int N); Remove the last N nodes from the linked list N>= 1 should be checked. If N> number-of-nodes then the resulting list will be empty. Your code should Not traverse the linked list more than 2 times. void LinkedListType::subtractNodes (LinkedListType & anotherList); Remove nodes if its value appears in one of the nodes in anotherList anotherList remains intact. For example, if the linked list is as follows: 23 -> 26-> 77-> 12 -> 33 and if anotherList is as follows: 15 -> 26-> 77-> 33 -> 66. Then after this function call, the linked list will be changed to 23 -> 12 Write the functions listed below for the LinkedListType class. DO NOT MAKE ANY CHANGES TO EXISTING CODE UNLESS THERE ARE SYNTAX ERRORS. void LinkedListType::duplicateRange (int low, int up); While traversing the given linked list, if you encounter a node whose int value, x, where low 26 -> 77-> 12-> 33, then the updated linked list should contain 23 -> 26-> 26-> 77 -> 12 -> 33 -> 33. If the linked list is empty, then no action is taken. void LinkedListType.removeEven(); While traversing the given linked list, if you encounter a node whose int value, x, is an even number, then remove that node. For example, for the given list 23 -> 26-> 77 -> 12-> 33, then the updated linked list should contain 23 -> 77-> 33. If the linked list is empty, then no action is taken. void LinkedListType::removeFirstN (int N); Remove the first N nodes from the linked list N>= 1 should be checked. If N> number-of-nodes, then the resulting list will be empty. Your code should Not traverse the linked list more than 1 time. void LinkedListType::removeLastN (int N); Remove the last N nodes from the linked list N>= 1 should be checked. If N> number-of-nodes then the resulting list will be empty. Your code should Not traverse the linked list more than 2 times. void LinkedListType::subtractNodes (LinkedListType & anotherList); Remove nodes if its value appears in one of the nodes in anotherList anotherList remains intact. For example, if the linked list is as follows: 23 -> 26-> 77-> 12 -> 33 and if anotherList is as follows: 15 -> 26-> 77-> 33 -> 66. Then after this function call, the linked list will be changed to 23 -> 12

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

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago