Question: I need help with this c++ code: int seqSearch(const int list[], int listLength, int searchItem, int &count) { count = 0; int loc; bool found

I need help with this c++ code:

int seqSearch(const int list[], int listLength, int searchItem, int &count)

{

count = 0;

int loc;

bool found = false;

for (loc = 0; loc

{

++count;

if (list[loc]==searchItem)

{

found = true;

break;

}

}

if (found)

{

return loc;

}

else

{

return -1;

}

}

int recSeqSearchActual(const int list[], int listLength, int searchItem, int &count)

{

if (listLength==0) return -1;

++count;

if (list[listLength]==searchItem)

{

return listLength;

}

else

{

return recSeqSearchActual(list, listLength-1, searchItem, count);

}

}

int recSeqSearch(const int list[], int listLength, int searchItem, int &count)

{

return recSeqSearchActual(list,listLength,searchItem,(count=0));

}

int binarySearch(const int list[], int listLength, int searchItem, int &count)

{

//ToDo

return -10;

}

int recBinarySearchActual(const int list[], int listLength, int searchItem, int first, int last, int &count)

{

//ToDo

// call itself with different parameters

return -10;

}

int recBinarySearch(const int list[], int listLength, int searchItem, int first, int last, int &count)

{

//ToDo

// call recBinarySearchActual()

return -5;

}

void bubbleSort(int list[], int listLength, int &count)

{

//ToDo

}

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 Databases Questions!