QuickTopic (SM) free message boards QuickTopic (SM) free message boards
Skip to Messages
  Sign In to access your topic list  |New Topic |My Topics|Profile
Upgrade to Pro   Customize, show pictures, add an intro, and more:   QuickTopic Pro...and check out QuickThreadSM
Topic: CSE 130 Homework #8
Views: 1485, Unique: 591 
Subscribers: 0
What's
this?
Printer-Friendly Page
Subscribe to get & post, or stop messages by email Subscribe
All messages            14-29 of 29  1-13 >>
About these ads
Who | When
Messagessort recent-top   
Post a new message
 
Omid  14
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
autumn  15
03-03-2004 10:49 PM ET (US)
Edited by author 03-03-2004 10:50 PM
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!
Sean O'RourkePerson was signed in when posted  16
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".
duy  17
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.
Sean O'RourkePerson was signed in when posted  18
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.
Beong  19
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]).?
mike  20
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
Sean O'RourkePerson was signed in when posted  21
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.
shaniqua  22
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.
Sean O'RourkePerson was signed in when posted  23
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.
need help(socail)  24
04-15-2006 04:37 PM ET (US)
Deleted by author 04-24-2006 11:57 AM
 
Messages 25-29 deleted by topic administrator between 07-10-2008 02:35 AM and 07-21-2006 08:59 AM
RSS link What's this?
All messages            14-29 of 29  1-13 >>
QuickTopicSM message boards
Over 200,000 topics served
Learn more Frequently asked questions  Acknowledgements
What they're saying about QuickTopic
 Questions, comments, or suggestions? Contact Us
Read our use policy before beginning. We value your privacy; please read our privacy statement.
Copyright ©1999-2008 Internicity Inc. All rights reserved.