8.1 Procedures sub1, sub2 and sub3, shown below, all implement the sublist relation. subl is a more...

Question:

8.1 Procedures sub1, sub2 and sub3, shown below, all implement the sublist relation. subl is a more procedural definition whereas sub2 and sub3 are written in a more declarative style. Study the behaviour, with reference to efficiency, of these three procedures on some sample lists. Two of them behave nearly equivalently and have similar efficiency. Which two? Why is the remaining one less efficient? sub1( List, Sublist) :- prefix( List, Sublist). sub1(Tail], Sublist) :- subl(Tail, Sublist). prefix([]). prefix( [X | List1], [X | List2]):- prefix( List1, List2). % Sublist is sublist of Tail sub2( List, Sublist) :- conc( List1, List2, List), conc( List3, Sublist, List1). sub3( List, Sublist) :- conc( List1, List2, List), conc( Sublist,, List2).

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: