+2 votes
733 views
in Artificial Intelligence by
Write a program that will take as input two Web page URLs and find a path of links from one to the other. What is an appropriate search strategy? Is bidirectional search a good idea? Could a search engine be used to implement a predecessor function?

1 Answer

0 votes
by (user.guest)
 
Best answer

Yes. Bidirectional search is good in this case.

Here's a sample code in C++

include<stdafx.h>

#include<iostream>

#include<conio.h>

using namespace std;

int s(int a[],int size,int num);

void main()

{ int num,i;

int a[7];

for(i=0;i<=6;i++)

{ cout<<" enter the number=";

cin>>a[i];

}

cout<<"\n\t enter the required no=";

cin>>num;

int size=7;

int save=s(a,size,num);

if(save==-1)

{ cout<<" not found ";

}

else

{cout<<" found "<<a[save]<<" at location "<<save;

}

getch();

int s(int a[],int size,int num)

{ int mid,low,high;

high=size-1;

low=0;

mid=size/2;

while(low!=high)

{ if(a[mid]==num)

{ return mid; }

else

{ if (a[mid]>num)

{ high=mid-1; }

else

{ low=mid+1; }

}

mid=(low+high)/2;

}

if (a[mid]==num)

{ return mid; }

else

{ return-1; }

}

Related questions

Welcome to CPEN Talk
Solution-oriented students of computer engineering on one platform to get you that

ONE SOLUTION

...