Question: 1. Construct the recursive diagram of the Remove function that invokes the function recursive getIndexOf using the main program described in your module. 2. Construct

1. Construct the recursive diagram of the Remove function that invokes the function

recursive getIndexOf using the main program described in your module.

2. Construct the recursive diagram of the getFrequencyOf function that invokes the function

recursive countFrequency using the main program described in your module.

Example of the recursive diagram that i need to implement in the main program.

  • display (): Funcin que imprime el contenido del arreglo

template

voidArrayBag::display()const{

cout <<"El contenido del arreglo:";

for(intindex = 0; index < getCurrentSize(); index++){

cout << items[index]<<",";

}//end for

cout << endl;

}

  • getFrequencyOf(): Busca la cantidad de ocurrencias recursivamente de un elemento dentro del arreglo

template

intArrayBag::getFrequencyOf(constItemType&anEntry)const

{

returncountFrequency(anEntry, 0);

}// end getFrequencyOf

template

intArrayBag::countFrequency(constItemType&target,intsearchIndex)const

{

if(searchIndex< itemCount)

{

if(items[searchIndex] ==target)

{

return1 + countFrequency(target,searchIndex+ 1);

}

else

{

returncountFrequency(target,searchIndex+ 1);

}// end if

}

else

return0;// Base case

}// end countFrequency

  • getIndexOf(): Retorna el indice donde se encuentra el elemento dentro del arreglo, en caso contrario retorna -1.

template

intArrayBag::getIndexOf(constItemType&target,intsearchIndex)const

{

intresult = -1;

if(searchIndex< itemCount)

{

if(items[searchIndex] ==target)

{

result =searchIndex;

}

else

{

result = getIndexOf(target,searchIndex+ 1);

}// end if

}// end if

returnresult;

}// end getIndexOf

C++ Main Program

#include

usingnamespace::std;

#include"ArrayBag.h"

intmain(){

ArrayBag myArrayInteger;

myArrayInteger.add(5);

myArrayInteger.add(3);

myArrayInteger.add(5);

myArrayInteger.add(10);

myArrayInteger.display();

myArrayInteger.remove(5);

myArrayInteger.display();

myArrayInteger.add(3);

myArrayInteger.add(3);

cout <<"El nuemo 3 esta "

<

<<"veces repetido en el arreglo ";

if(myArrayInteger.contains(7)){

cout<"El numero 7 esta dentro del arreglo ";

}

else{

cout<<"El numero 7 no esta dentro del arreglo ";

}

system("pause");

return0;

}//end main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!