Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi there, I need some help writing a function definition as a recursive search a

ID: 3528562 • Letter: H

Question

Hi there, I need some help writing a function definition as a recursive search assuming an array-based and a linked list implementation. Here is the prototype for the SortedType function: void SortedType :: Search (int value, bool& found); I do not need the actual code in C++ the ADT form is preferred (abstract) Thanks

Explanation / Answer

int IndexMatch(int arr[], int size) { if(size < 2) return -1; int cursor = Compare(arr, size-1, arr[size-1], size-1); if(cursor > -1) return cursor; else return IndexMatch(arr, size-1); } //helper function definition int Compare(int arr[], int size, int target, int curs) { if(size < 1) return -1; else if(target == arr[curs-1]) return curs-1; else return Compare(arr, size - 1, target, curs-1); } linked list implementation struct node { int data; node *ptr; }; void main() { node *st = NULL; st = new node(); st->data=10; st->ptr=NULL; node *temp; for(int i=1; idata = 10+i; temp->ptr =NULL; } getch(); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote