Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

In c++ code the following UMLs

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

+determineMiddle(node:item*):item *

-midpointRecursion(t:item*, n:int *, midpoint:item**):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.

minNode: This function returns the smallest value, that is the smallest T value in

the list.

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

from 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.

determineMiddle: This is the wrapper function for the recursive function which is

midpointRecursion. This function returns the node that is located at the midpoint

of the list. The midpoint is dened as being the node with equal number of nodes

before it, and then after it. You can assume that the lists will always have a

convenient midpoint, that is, the list will always be odd numbered in size so that

a midpoint, with equal numbers of nodes after and before, will exist. For example,

the list:

4->5->6->7->1->2->9

The midpoint of this list is is 7 as at 7, 3 nodes are before and 3 nodes are after.

midpointRecursion: This is a helper function that actually performs the recursive

step. It takes a starting node, an index, and a midpoint which is actually the part

that is going to be returned out through the use of references. The index variable is

used to control the position of the iteration. It controls where in the list the current

recursive step is.

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 and a makele.

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

Students also viewed these Databases questions

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago