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: 1492, Unique: 596 
Subscribers: 0
What's
this?
Printer-Friendly Page
Subscribe to get & post, or stop messages by email Subscribe
All messages    << 14-29  1-13 of 29        
About these ads
Who | When
Messagessort recent-bottom   
Post a new message
 
shaniqua  13
03-03-2004 07:30 PM ET (US)
i correct myself. a better example is [1, 2, 3, 1, 2, 3, 1, 2, 3]
shaniqua  12
03-03-2004 07:26 PM ET (US)
sean, i think your explanation of 11.2d is a bit off. You do have a string of 3 substrings, but the question asks for lists and sublists. So would a more appropriate example be [123, 123, 123]?
laughter  11
03-03-2004 07:11 PM ET (US)
Deleted by author 03-03-2004 07:15 PM
Lucy  10
03-03-2004 05:22 PM ET (US)
Do I need to implement 11.2, 11.4, and 11.5 all in prolog?
Sean O'RourkePerson was signed in when posted  9
03-02-2004 05:02 PM ET (US)
Edited by author 03-02-2004 05:03 PM
Alaska - Thomas is correct only for part (a). For part (c), please use my interpretation: a list is the concatenation of zero or more runs R_i of elements, where each run R(e,n) consists of n identical elements e, n >= 0. Your job is to define a relation such that a list
    R(e_1,n_1) ... R(e_k, n_k)
is related to another list
    R(e_1,m_1) ... R(e_k, m_k)
where
    m_j = 1 if n_j > 1, and m_j = 0 otherwise.
In the example, "2" and "4" were not included in the output, because they were contained in runs of only a single element.

(11.2d) "abcabcabc" is a string consisting of three copies of the same substring, "abc".
alaska  8
03-02-2004 03:56 PM ET (US)
i don't understand 11.2 part d. What does it mean by " a list is a concatenation of three copies of the same sublist". What does it mean by three copies of the same sublist? Thanks
alaska  7
03-02-2004 03:38 PM ET (US)
Sean, I still don't understand your explanation. Could you tell me the difference between part a and part c. Is Thomas intepretation on part a and c correct?. Thanks
Sean O'RourkePerson was signed in when posted  6
03-02-2004 12:58 PM ET (US)
Edited by author 03-02-2004 12:58 PM
Lee - "relation" is the Prolog-word for "function" (more or less -- they're not the same thing). E.g. "parent(sean,peter)." defines the "parent" relation for "sean" and "peter".

TC -- I found this confusing as well. I interpret part C as "keep one copy of elements with adjacent duplicates, and no copies of anything else", e.g.

[1,1,2,3,3,4,5,5] ==> [1,3,5]

Unless someone else mentions an obviously better interpretation, let's stick with this one.

David -- you'll have to give me a bit more detail.
David  5
03-02-2004 05:47 AM ET (US)
Deleted by author 03-02-2004 06:03 AM
Thomas Cunningham  4
03-02-2004 04:33 AM ET (US)
Edited by author 03-02-2004 04:39 AM
For problem 11.4, what is the difference between part a and part c? It seems to me that the question is poorly worded.

Here's how I've interpreted it:
Part a pairs [1,1,1,2,2,1,3] and [1,2,1,3].
Part c pairs [1,1,1,2,2,1,3] and [1,2,3].

In words:
In part a if a cluster of atoms is encountered, keep a single copy of that atom in the position of the cluster.
In part c if a cluster of atoms is encountered, keep a single copy of that atom in the position it is first encountered. Delete all other instances of that atom, even if they are not in a cluster.

This just doesn't seem correct, however.
Lee  3
03-02-2004 04:22 AM ET (US)
for 11.4 what does that mean "define relation correponing to the operation". Can anyone give me an example? thnaks a lot.
Sean O'RourkePerson was signed in when posted  2
03-01-2004 11:14 PM ET (US)
For those of you who were in discussion today, here's a correct and functional implementation of bubble-sort in Prolog:

bsort([],[]).
bsort([A|B],[C|E]) :- bsort(B,D), bubble([A|D],[C|E]).

bubble([],[]).
bubble([A],[A]).
bubble([A,B|C], [A|D]) :- A < B, bubble([B|C], D).
bubble([A,B|C], [B|D]) :- A >= B, bubble([A|C], D).
Sean  1
03-01-2004 10:49 PM ET (US)
How to run prolog... See

http://www.cs.ucsd.edu/classes/wi00/cse130/prolog.html

In particular: "Type sbprolog at the prompt to start the interpreter. If your prolog code is in a file named prologCode, type consult(prologCode) to load your program. It is better to avoid . character in file names.(That is, avoid file extensions for Prolog programs.) Type control-D to exit the interpreter."
RSS link What's this?
All messages    << 14-29  1-13 of 29        
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.