Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete this PROLOG program to find a path on the map in Figure 3.2 between any pair of cities. Be sure the path you find

Complete this PROLOG program to find a path on the map in Figure 3.2 between any pair of cities. Be sure the path you find is acyclic, i.e., has no loops like [a,s,r,p,c,s,r,b]. adjacent(a,t). adjacent(a,s). adjacent(a,z). adjacent(s,o). adjacent(s,f). adjacent(s,r). adjacent(o,a). adjacent(f,b). adjacent(r,p). adjacent(p,b). %path(P,Start,Goal) means P is a path from Start to Goal path([X,Y],X,Y):-adjacent(X,Y). path([X,Y],X,Y):-adjacent(Y,X). path([Goal],Goal,Goal). path([Start|[Head|Tail]],Start,Goal):-adjacent(Start,Head),path([Head|Tail],Head,Goal). Name your program PATH.pl. Hint: PROLOG checks predicates in order, so choose the order carefully.

image text in transcribed

Oradea Neamt 87 Zerind 151 75 Iasi Arad 140 92 Sibiu Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 211 Pitesti Lugoj 97 70 98 Hirsova Mehadia 146 101 85 Urziceni 86 75 138 Bucharest Drobeta 120 90 Craiova Eforie Giurgiu Figure 3.2 A simplified road map of part of Romania Oradea Neamt 87 Zerind 151 75 Iasi Arad 140 92 Sibiu Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 211 Pitesti Lugoj 97 70 98 Hirsova Mehadia 146 101 85 Urziceni 86 75 138 Bucharest Drobeta 120 90 Craiova Eforie Giurgiu Figure 3.2 A simplified road map of part of Romania

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions