#include #include #include #include using namespace std; class interpolition { public: int i,j=0,j1=0,j2=0,j3=0; vectora; vectora1; vectora2; vectora3; void input(int n) { a[j]=n;j++; } void input(double n) { a1.push_back(n); } void input(char n) { a2.push_back(n); } void input(string n) { a3.push_back(n); } void sorting() { if(a.size()!=0) {sort(a.begin(),a.end()); } if(a1.size()!=0) {sort(a1.begin(),a1.end()); } if(a2.size()!=0) {sort(a2.begin(),a2.end()); } if(a3.size()!=0) {sort(a3.begin(),a3.end()); } } int binary(int x) { int s=0,l=a.size(),c=0,mid; do { c=0; mid=(l-s/(a[l]-a[s]))*(x-a[s]); if(a[mid]==x) { return mid; } if(a[mid]>x) { l=mid-1; } if(a[mid]x) { l=mid-1; } if(a1[mid]x) { l=mid-1; } if(a2[mid] st1) { hi=pos-1; } else { low=pos+1; } } return -1; } }; int main() { interpolition b; int ch; cout<<"what is the datatype of input:-\n1. int\n2. double\n3. char\n4. string"<>ch; switch(ch) { case 1: { int n,m; do { cout<<"enter the value to be inserted in array:-"; cin>>n; b.input(n); cout<<"do you want to add more elements? 1. yes 2. no\n"; cin>>m; }while(m!=0); b.sorting(); int x; cout<<"enter the value to be searched in array:-"; cin>>x; int k=b.binary(x); if(k==-1) { cout<>n; b.input(n); cout<<"do you want to add more elements? 1. yes 2. no\n"; cin>>m; }while(m!=0); b.sorting(); double x; cout<<"enter the value to be searched in array:-"; cin>>x; int k=b.binary(x); if(k==-1) { cout<>n; b.input(n); cout<<"do you want to add more elements? 1. yes 2. no\n"; cin>>m; }while(m!=0); b.sorting(); char x; cout<<"enter the value to be searched in array:-"; cin>>x; int k=b.binary(x); if(k==-1) { cout<>n; b.input(n); cout<<"do you want to add more elements? 1. yes 2. no\n"; cin>>m; }while(m!=0); b.sorting(); string x; cout<<"enter the value to be searched in array:-"; cin>>x; int k=b.binary(x); if(k==-1) { cout<