Scheme, computer science, Basic Computer Science

There is a path between two vertices if there is a series of edges that you can use to travel between them. For example, between vertices 1 and 3 above, there is a path made up of the edges (1 2) and (2 3), written ((1 2)(2 3)). A path may not include repeated vertices.
Write two functions: in Scheme, a predicate path?, which takes a graph and two numbers indicating vertices, which returns true iff there is a path between them.:

(path? ''(5 ((1 2)(2 3)(3 4)(3 5)(4 5))) 1 5)
#t
(path? ''(5 ((1 2)(3 4)(3 5)(4 5))) 1 5)
#f

In Prolog, write a query path(+G, +V1, +V2) which succeeds iff there is a path in graph G between vertices V1 and V2.

path(graph(5, [[1,2],[2,3],[3,4],[3,5],[4,5]]), 1 5).
true.
path(graph(5, [[1,2],[3,4],[3,5],[4,5]]), 1 5).
false.
Posted Date: 2/24/2012 10:23:35 AM | Location : United States







Related Discussions:- Scheme, computer science, Assignment Help, Ask Question on Scheme, computer science, Get Answer, Expert's Help, Scheme, computer science Discussions

Write discussion on Scheme, computer science
Your posts are moderated
Related Questions

Suppose that of 100 computers checked for viruses 30 where infected and 70 where not. If we select 10 computers at random what is the probability that at most 4 of them are infecte

Subroutine and Functions:  In a program, it is often necessary to repeat a statement or group of statements at several points to accomplish a particular task. Repeating the sa

Question 1 Explain the configuration steps involved in CMOS setup Date and time Error halt Floppy drive A Halt on Hard disk C HDD Delay Keyboard Memory

what is rom

QUESTION (a) Write down the Update Step in the Dijkstra's algorithm explaining its complexity. (b) Propose a Generic Algorithm for Depth-First Search Algorithm, assuming

What is a Structure?

Command Processor and User Interface: To the user, the most important and visible services provided by the OS is the user interface and the capabilities that it provides to ex

Number data types store numeric values. They are an immutable data type, which means that changing the value of a number data type results in a newly allocated object. Number objec