![:oops:](./images/smilies/icon_redface.gif)
#include<iostream>
using namespace std;
int count=0;
int temp=0;
int main ()
{
int a[100]; //Source array
int b[100]; //Destination array
int l=0,p=0,k=0,c;
char u;
cout<<"Enter root value:";
cin>>a[0]; //setting the root
cout<<endl;
//==============================Input Block==============
while(k<100)
{
for(static int i=0;i<=k;i++)
{
cout<<"Enter source:"<<endl;
cin>>a;
}
for(static int j=0;j<=k;j++)
{
cout<<"Enter destination:"<<endl;
cin>>b[j];
}
cout<<"want to enter more node press 'y' or check is it a tree press 'N'!"<<endl;
cin>>u;
if(u=='Y' || u=='y')
{
k++;
}
else
{
k=101;
}
}
//=============================basic logic of finding , is it a tree !!===========//
while(l<100)
{ temp=b[l];
for(p=0;p<100;p++)
{
if(count<2)
{
if(temp==b[p])
{
count++;
}
}
else
{
p=101;
l=101;
}
}
if(count==2)
{
l=101;
}
else
{
count=0;
l++;
}
}
if(count>=2)
{
cout<<"it is not a tree!"<<endl;
}
else
{
cout<<"it is a tree!"<<endl;
}
return 0;
}
help me out guys!!