A sequential search member function of SortedType has the followingprototype: vo
ID: 3644914 • Letter: A
Question
A sequential search member function of SortedType has the followingprototype:void SortedType::Search(int value, bool&found);
(a) Write the function definition as a recursive search, assuming a linked list implementation.
PLEASE BE CLEAR IN YOUR SOLUTION...THIS IS A MUST...NOEXCEPTIONS..THIS CONCEPT IS DONE IN C++/DATA STRUCTURES..NO OTHERPROGRAMMING LANGUAGE PLEASE
Explanation / Answer
#include struct node { int data; node* link; }; class SortedType { node* first; public: SortedType(){ first=NULL; } void getdata(int x); void display(); void search(int vallue, int& x); }; void SortedType:: getdata(int x) { node* pnew=new node; pnew->data=x; pnew->link=NULL; if(first==NULL) first=pnew; else { node* ptr=first; while(ptr->link!= NULL) ptr=ptr->link; ptr->link=pnew; } } void SortedType :: display() { node* ptr=first; while(ptr) { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.