top bar
QuickTopic free message boards logo
Skip to Messages

TOPIC:

CSE 130 Homework #8

^     All messages            14-29 of 29  1-13 >>
  Messages 29-24 deleted by topic administrator between 07-10-2008 02:35 AM and 04-24-2006 11:57 AM
23
Sean O'RourkePerson was signed in when posted
03-04-2004
05:11 PM ET (US)
shaniqua -- Yes, you can just write a query if you want. Since a query is basically the right-hand side of a relation, you can also write a relation encoding the desired... err... relation in terms of append. If you do just write a query, make sure that your query's strategy works for all inputs, not just the ones you chose.
22
shaniqua
03-04-2004
04:27 PM ET (US)
Sean, i think your latest response is a bit confusing. I know append is already defined by prolog, yet you say we should write a relation? It's my understanding that the 11.2 asks us to use only the given append relation, and to formulate queries to do accomplish the appropriate tasks.

Essentially, we don't need to write further relations, and just need queries.
21
Sean O'RourkePerson was signed in when posted
03-04-2004
04:17 PM ET (US)
Beong -- no. Your solution should work for any input.

Mike -- append is already defined by your prolog. You should write a relation.
20
mike
03-04-2004
02:54 PM ET (US)
for 11.2 a)
do we have to write a relation function such as
third(.....) -append(..).
or can we just simply use the relation given:
append([], Y, Y).
append([H|X], Y, [H|Z]) :- append(X, Y, Z).

and just run queries in console
19
Beong
03-04-2004
02:25 PM ET (US)
In 11.2, do we assume that we know the all the items in the list? for example, if we wanted to get the first item in a list do we do something like
append([X], [b,c,d,e], [a,b,c,d,e]).?
18
Sean O'RourkePerson was signed in when posted
03-04-2004
02:02 PM ET (US)
Duy -- that sounds fine. You should hand in both the file containing your relations, and a transcript of the queries you used to test them. For 11.2, you should define relations, not just do queries.
17
duy
03-04-2004
11:14 AM ET (US)
how do we supposed to show our answers. Like for 11.2, you make queries. How do you supposed to write a program with it. I just load the facts, and enter the queries at the command. Is that ok? or do I have to put queries in the program itself because i tried prof example of ex.pl(or ex) it doesn't work, the one on the indoEuropean thing.
16
Sean O'RourkePerson was signed in when posted
03-04-2004
09:17 AM ET (US)
Shaniqua -- that is a correct example.

Omid -- remember that you can have a variable as part of a complex expression in prolog, so e.g.
    [1,A,2|B]
means "a list consisting of '1', then something, then '2', then zero or more elements".

For part 3, it should be _easier_ to write BSTs in prolog ;). The general idea when doing data structures without assignment is to (conceptually) create a whole new copy with the necessary changes. In prolog, this looks like:
    modification(OldVersion, ..., NewVersion) :- ...
i.e. a relation between the old and new versions of a data structure. Think of the recursive version of binary tree insertion, and try to formulate that as clauses of a relation.

autumn -- if it can't satisfy the relation, it will print out "no". If it can, it will print out a list of variable bindings, then a "?" to ask if you want more solutions. Just press enter. It should then print out "yes".
15
autumn
03-03-2004
10:49 PM ET (US)
I'm quite confused on question 11.4a
say after compling by typing consult(myrelation).
then I typed:
myrelation([something,something], [anything,anything]).
after hitting the enter what does it suppose to display?

any help will be appreciated!
Edited 03-03-2004 10:50 PM
14
Omid
03-03-2004
09:33 PM ET (US)
i'm lost on the last 2 problems.

most of this comes out of the fact that i dont know any prolog, so some syntax help would be nice.

prob 2:
how do we go about checking seperate elements in the list

prob 3: binary search tree in prolog?!?!?!?!? this is hard enough in an imperative lang.
the text gives a good example how to find an element, which i assume we should incoorporate when inserting and deleting, but how would we insert if we can't assign anything anywhere?

help is appreciated.

thanks

Omid
13
shaniqua
03-03-2004
07:30 PM ET (US)
i correct myself. a better example is [1, 2, 3, 1, 2, 3, 1, 2, 3]
^     All messages            14-29 of 29  1-13 >>

Print | RSS Views: 1790 (Unique: 762 ) / Subscribers: 0 | What's this?