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
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
{
returncountFrequency(anEntry, 0);
}// end getFrequencyOf
template
intArrayBag
{
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
{
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.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
Get step-by-step solutions from verified subject matter experts
