Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code the following UMLs in c++ 2.2 Task 1 2.2.1 rLL The rLL is the recursive linked list class. It has the following denition based

Code the following UMLs in c++

2.2 Task 1

2.2.1 rLL

The rLL is the recursive linked list class. It has the following denition based on the

simple UML diagram below:

rLL

-head: item*

-size: int

----------------------------

+rLL()

+~rLL()

+getHead(): item*

+push(newItem:item*):void

+pop():item*

+minNode():T

+getSize():int

+recursivePrint(c:item * ):void

+recursiveAltPrinting(node:item * , odd:bool):void

The class variables are as follows:

head: The head pointer of the linked list.

size: The current size of the linked list. This starts at 0 and increases as the list

grows in size.

The class methods are as follows:

rLL: The class constructor. It starts by setting the variables to null and 0 respec-

tively.

rLL: The class destructor. It will deallocate all of the memory in the class.

getHead: This returns the head pointer of the linked list.

push: This adds a new item to the linked list, by adding it to the front of the list.

pop: This returns the top item of the linked list. The item is returned and removed

from the list.

minNode: This returns the smallest value found in the list.

getSize: This returns the current size of the linked list.

recursivePrint: This function receives a node and then recursively prints out the

node's data until the end of the list. Note that it should be able to print from any

point in the list, not just from head. If the linked list, for argument sake, looked

like

4->3->5->1->7

and then the second node,3, was passed in, the resulting print should produce the

following, with comma delimiters:

3,5,1,7

The last one should should be printed out with a new line.

recursiveAltPrinting: This function is an adaptation of the normal printing method.

Rather than printing every node in order, it will only print ever other node, starting

by printing the rst node and then every alternative node. For example if the list

looks like

10->9->8->7->6->5->4

Then the resulting printing operation, which should be comma delimited and end

with a new line. This would be:

10,8,6,4

You can assume that the minimum size of the lists that will be tested will be at

least 3.

2.2.2 item

The class is described according to the simple UML diagram below:

item

-data:T

-------------------

+item(t:T)

+~item()

+next: item*

+getData():T

The class has the following variables:

data: A template variable that stores some piece of information.

next: A pointer of item type to the next item in the linked list.

The class has the following methods:

item: This constructor receives an argument and instantiates the data variable with

it.

item: This is the destructor for the item class. It prints out "X:Item Deleted"

with no quotation marks and a new line at the end. The X in this case refers to the

data of the item.

getData: This returns the data element stored in the item.

You will be allowed to use the following libraries: string, iostream.

Your submission must contain item.h,item.cpp,rLL.h,

rLL.cpp, main.cpp.

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

8. Provide recommendations for how to manage knowledge.

Answered: 1 week ago