Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ 1. Your Own Linked List Design your own linked list class to gold a series of integers. The class should have member functions

In C++

1. Your Own Linked List

Design your own linked list class to gold a series of integers. The class should have member functions for appending, inserting, and deleting nodes. Don't forget to add a festructor that destroys the list. Demonstrate the class with a driver program.

2. List Print

Modify the linked list class you created in Challenge 1 to add a print member function. The funtion should display all the values in the linked list. Test the class by starting with an empty list, adding some elements, and then printing the result.

3. Member Insertion by Position

Modify the list class you created in the previous programming challeneges by adding a member function for inserting a new item at a specified position. A position of 0 means that the value will become the first item on the list, a position of 1 means that the value will become the second item on the list. A position equal to or greater than the length of the list means that the value is placed at the end of the list.

4. Member Removal by Position

Modify the list class you created in the previous programming challenges by adding a member function for deleting a node at a specified postition. A value of 0 for the position means that the first node in the list (the current head) is deleted. The function does nothing if the specified position is greater than or equal to the length of the list.

Use this header file for the list:

// Specification file for the IntList class #ifndef INTLIST_H #define INTLIST_H

class IntList { private: // Declare a structure for the list struct ListNode { int value; struct ListNode *next; };

ListNode *head; // List head pointer

// Destroy function void destroy();

public: // Constructor IntList() { head = nullptr; }

// Destructor ~IntList();

// List operations void appendNode(int); void insertNode(int); void deleteNode(int); void print(); void insert(int, int); void removeByPos(int); };

#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_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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

=+ a. Explain why investment might depend on national income.

Answered: 1 week ago