You assistance would be greatly appreciated with the following question thanks i
ID: 3540863 • Letter: Y
Question
You assistance would be greatly appreciated with the following question thanks in advance:
A sequential search member function of SortedType has the following prototype:
void SortedType::Search(int value, bool& found);
a. write the function definition as a recursive search, assuming a linked list implementation.
b. write the function definition as a recursive search, assuming an array base implementation.
Please show where the answer to "a" ends, and the beginning for "b" begins. Please show all work. Thanks again.
Explanation / Answer
answer a.
u have previously declare a linked list for that
void SortedType::Search(int value,node *p)
{
int count=0;
while(p->val != null) // val is a variable of linked list
{ count++;
if( p->val==value)
{
cout<<"value found at location "<<count;
p=p->next;
} }}
-----------------------------------------------
answer b.
void SortedType::Search(int value, int size,int a[])
{
for(int i=0;i<size;i++)
{
if(a[i]==value)
{cout<<"value found at location "<<i;
}}}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.