tag:blogger.com,1999:blog-687746891001673501.post1800825655949159548..comments2023-06-03T07:18:38.584-07:00Comments on Data Structures in C: Linear SearchUnknownnoreply@blogger.comBlogger6125tag:blogger.com,1999:blog-687746891001673501.post-85798501575645054322016-10-28T06:46:35.569-07:002016-10-28T06:46:35.569-07:00#include
using namespace std;
class searc
{
public...#include<br />using namespace std;<br />class searc<br />{<br />public:<br /> int DATA[5]={1,2,3,4,5},item=2,n=5,loc=-1,k=0;<br /> searc()<br /> {<br /> while(loc==-1&&k<n)<br /> {<br /> if(item==DATA[k])<br /> loc=k;<br /> k=k+1;<br /> }<br /> if(loc==-1)<br /> cout<<"item is not present"<<endl;<br /> else<br /> cout<<"The location of item is="<<loc<<endl;<br /> }<br /> ~searc()<br /> {<br /><br /> }<br />};<br />int main()<br />{<br /> searc s;<br />}<br /><br /><br />Anonymoushttps://www.blogger.com/profile/10596717868855450954noreply@blogger.comtag:blogger.com,1999:blog-687746891001673501.post-32262568145968834862016-10-28T06:07:37.617-07:002016-10-28T06:07:37.617-07:00#include
using namespace std;
class searc
{
public...#include<br />using namespace std;<br />class searc<br />{<br />public:<br /> searc()<br />{<br /> int DATA[10]={1,2,3,4,5,6,7,8,9,19};<br /> int N,LOC,K,ITEM;<br /> N=10;<br /> K=0;<br /> LOC=11;<br /> ITEM=22;<br /> while(LOC==11 && K<N)<br /> {<br /> if(ITEM==DATA[K])<br /> LOC=K;<br /> K=K+1;<br /> }<br /> if(LOC==11)<br /> cout<<"Item is not in array"<<endl;<br /> else<br /> cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";<br /><br />}<br />~searc()<br />{<br /><br />}<br />};<br />int main()<br />{<br /> searc c;<br />}<br /><br /><br /><br />Zubair (201610287)https://www.blogger.com/profile/16191114871133063382noreply@blogger.comtag:blogger.com,1999:blog-687746891001673501.post-34052926463979378962016-10-26T09:05:33.022-07:002016-10-26T09:05:33.022-07:00#include
using namespace std;
class linear
{
publi...#include<br />using namespace std;<br />class linear<br />{<br />public:<br /> int DATA[8]={2,3,4,5,6,7,8,9},n=8,item=5,k=0,loc=-1;<br /> linear()<br /> {<br /> while(loc==-1 && k<n)<br /> {<br /><br /> if(item==DATA[k])<br /> loc=k;<br /> k+=1;<br /> }<br /> if(loc==-1)<br /> cout<<"item is not present"<<endl;<br /> else<br /> cout<<"the locatiion of the item="<<loc<<endl;<br /> }<br /> ~linear()<br /> {<br /><br /> }<br />};<br />int main()<br />{<br /> linear l;<br />}<br />Ferzana konahttps://www.blogger.com/profile/13072977427959267130noreply@blogger.comtag:blogger.com,1999:blog-687746891001673501.post-84126747954028526882016-10-26T09:02:45.298-07:002016-10-26T09:02:45.298-07:00#include
using namespace std;
class linear
{
publi...#include<br />using namespace std;<br />class linear<br />{<br />public:<br /> int DATA[8]={2,3,4,5,6,7,8,9},n=8,item=5,k=0,loc=-1;<br /> linear()<br /> {<br /> while(loc==-1 && k<n)<br /> {<br /><br /> if(item==DATA[k])<br /> loc=k;<br /> k+=1;<br /> }<br /> if(loc==-1)<br /> cout<<"item is not present"<<endl;<br /> else<br /> cout<<"the locatiion of the item="<<loc<<endl;<br /> }<br />};<br />int main()<br />{<br /> linear l;<br />}<br />Ferzana konahttps://www.blogger.com/profile/13072977427959267130noreply@blogger.comtag:blogger.com,1999:blog-687746891001673501.post-60877192570691570352016-10-25T09:46:03.611-07:002016-10-25T09:46:03.611-07:00// with destructor
#include
using namespace std...// with destructor<br /><br /><br /><br />#include<br />using namespace std;<br />class searc<br />{<br />public:<br /> searc()<br />{<br /> int DATA[10]={1,2,3,4,5,6,7,8,9,19};<br /> int N,LOC,K,ITEM;<br /> N=10;<br /> K=0;<br /> LOC=11;<br /> ITEM=22;<br /> while(LOC==11 && K<N)<br /> {<br /> if(ITEM==DATA[K])<br /> LOC=K;<br /> K=K+1;<br /> }<br /> if(LOC==11)<br /> cout<<"Item is not in array"<<endl;<br /> else<br /> cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";<br /><br />}<br />~searc()<br />{<br /><br />}<br />};<br />int main()<br />{<br /> searc c;<br />}<br /><br /><br /><br />Zubair (201610287)https://www.blogger.com/profile/16191114871133063382noreply@blogger.comtag:blogger.com,1999:blog-687746891001673501.post-71934347289341244142016-10-25T09:39:48.379-07:002016-10-25T09:39:48.379-07:00#include
using namespace std;
class searc
{
public...#include<br />using namespace std;<br />class searc<br />{<br />public:<br /> searc()<br />{<br /> int DATA[10]={1,2,3,4,5,6,7,8,9,19};<br /> int N,LOC,K,ITEM;<br /> N=10;<br /> K=0;<br /> LOC=11;<br /> ITEM=5;<br /> while(LOC==11 && K<N)<br /> {<br /> if(ITEM==DATA[K])<br /> LOC=K;<br /> K=K+1;<br /> }<br /> if(LOC==11)<br /> cout<<"Item is not in array"<<endl;<br /> else<br /> cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";<br /><br />}<br />};<br />int main()<br />{<br /> searc c;<br />}<br /><br /><br />Zubair (201610287)https://www.blogger.com/profile/16191114871133063382noreply@blogger.com