Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1: ListNode Class (3 points) Write the class definition for ListNode class (node in linked list), assuming the data type is int. The class

Task 1: ListNode Class (3 points)

Write the class definition for ListNode class (node in linked list), assuming the data type is int. The class should include:

The member variables

the accessor and mutator functions for each member variable.

a default constructor

a value constructor that initializes all member variables. Define all the member functions outside the class definition. Use const modifier for member functions when appropriate.

Task 2: LinkedList Class (7 points)

Write the class definition for LinkedList class. The class should include:

the member variable

the accessor and mutator function

a default constructor

a value constructor that initializes member variable

a constructor that builds a linked list from an int array. Think about what function parameter(s) this function should have

define some member functions (operations to the list) that are important for this class, and implement at least the following member functions: o display: print every node in the list o preAppend: append a node to the beginning of the list. o another function of your choice

Use const modifier for function parameters and member functions when appropriate. Write a driver to test two classes (including member functions).

This is what I have:

#include

using namespace std;

class Node{

public:

Node();

Node(int node, Node *nextNode);

void setData(int newValue);

void setNext(Node *newValue);

int getData(void) const;

Node * getNext(void) const;

private:

int data;

Node *nextNode;

};

class List

{

public:

List();

List(Node *head);

List(const int *arrayList, int arraySize);

void display(void);

void preAppend(ListNode *init); //append at the front

void posAppend(int nodeNum); //append at the end

void setList(ListNode *head);

Node getList(void) const;

private:

Node *head;

};

int main(int argc, const char * argv[]) {

// insert code here...

return 0;

}

THANK YOU!

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

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions