Google Answers Logo
View Question
 
Q: Algorithms in Computer Science ( No Answer,   0 Comments )
Question  
Subject: Algorithms in Computer Science
Category: Computers > Algorithms
Asked by: budigi-ga
List Price: $10.00
Posted: 15 Dec 2002 18:20 PST
Expires: 14 Jan 2003 18:20 PST
Question ID: 125142
Give the fastest, correct algorithm you can for solving the
composition problem.  Analyze your algorithm, stating and justifying
the complexity. onsider space as well as time.
    Let A = {a,b,c,…z}, the set of letters in the English alphabet.
Given an integer n, an array W[0,…,n-1] and a string y.  The array W
contains n strings or words made up of letters in A.  The words in W
have length <= n. Does there exist an integer k and a function f: Zk
-> Zn such that y = W[f(0)]*W[f(1)]*….*W[f(k-1)]?  * is the
concatenation operator.  In other words, is y a concatenation of words
in W?  Note: Zi is subset or equal of Z such that Zi = { 0, 1, … i –1
}.
Example: Suppose n = 7 and W = [a, ab, acb, bab, bb, bcb, cc],  If  y
= abbabab then y = ab*bab*ab so the answer is Yes.  If y = babbacc
then the answer is NO.  k = 3.   And f(0) = 1, f(1) = 3, f(2) = 1.

Request for Question Clarification by rbnn-ga on 18 Dec 2002 11:20 PST
There are a couple of issues here.

First, the phrase "fastest algorithm" is ambiguous. It is necessary to
specify a metric by which to measure "fastest" (e.g., worst case or
average case; over which distribution of inputs). Generally in
discussin algorithm theory  we would mean by fastest "smallest
worst-case asymptotic complexity" over some measure of size of the
inputs; however, if you are writing a text editor, for example, you
might have another metric in mind.

Second, the sentence "Given an integer n, an array W[0,…,n-1] and a
string y." is not grammatical. In particular, it is not clear to me
whether you are fixing n and W and have as input a string y to the
algorithm (in which case a trivial linear algorithm exists) or whether
the input to the algorithm is the triple {n,W,y} , in which case I
don't see any worst-case asymptotically better way than brute force
with quadratic complexity.

Third, to design and to explain an algorithm would require much more
time for me than the pricing guidelines at
http://answers.google.com/answers/pricing.html suggest for $10.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy