I think it's not justified to say that string concat is O(n m), one has to distinguish
| This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||
| ||||||||||||||||||
I think it's not justified to say that string concat is O(n+m), one has to distinguish
On the other hand, if one uses reference counting and allows for segmented string storage, then the concatenation takes virtually no time.
Concerning "memoization", why the heck did this guy not call it memorization ??? (Or memo'ization ?)
And finally, I would be astonished if there was no better ("local") method for optimizing this matrix problem, rather than checking all possible combinations... I'll think about this... MFH 13:43, 24 Mar 2005 (UTC)
I had a hard time understanding the pseudocode because of the variable 'l', which is defined in the outer-most main loop. The statements "n-l+1" and "i+l-1" appeared to me as "n-1+1" and "i+1-1". (I could not distinguish the 'l' variable from the '1'. In anti-aliased Courier New font, the difference was very small for my eye to see.)
I first thought that these statements may be intended by the writer to indicate that 1 was removed for some reason and added for a different reason (as when a loop is said to run (n-1)+1 times). I then couldn't figure out the reasons, and it took me quite some time to understand that it is an 'l'. (Actually I was already writing in the discussion page to ask how the algorithm could be like that - it would be definitely wrong.)
I wish you could take this into consideration (in this and other articles), and use a variable other than 'l'. In this specific algorithm, the name "len" may be good.
Thanks. --Hosam Aly 19:39, 7 January 2007 (UTC)
Although this problem is often quoted as a good way to teach dynamic programming, the resulting O(n^3) time complexity is very poor compared to the best known. O(n log n) time can be achieved by observing that the problem can be reduced to that of finding the minimum weight triangulation of a polygon.
87.194.206.189 (talk) 13:06, 21 December 2008 (UTC)
PRINT-OPTIMAL-PARENS(s, i, j)
if i=j
print ′′A′′i ;
else
print ”(”; PRINT-OPTIMAL-PARENS(s, i, s[i, j]) PRINT-OPTIMAL-PARENS(s, s[i, j]+1, j) print ”)”
this is the pseudocode to find final order of the matrix multiplication but i am having problem in solving the problem manually —Preceding unsigned comment added by Pathakamit90 (talk • contribs) 02:19, 14 February 2010 (UTC)
This page needs a lot more setup. It might help to say things like multpling an nxm by a mxk n*m*k, and that order matters (before getting into the example) and that this is a common problem. 018 (talk) 19:18, 11 October 2011 (UTC)
The following research may be used in support of this page (SIAM as well as Hu and Shing apparently have been considered reliable enough for wikipedia for years):
Also, these provide enough information to write a History section about the Matrix Chain Ordering Problem. R.J.C. van Haaften (talk) 21:57, 23 January 2015 (UTC)
This seems to be the place to provisionally plug
For lack of reachability of JofCIS and fear of disappearance:
Algorithm Unimodal()
Initialize()
cost(rn-2) ← w(vt-1)w(vt)w(vt+1)
crit(rn-2) ← cost(rn-2) ⁄ W(rn-2)-w(vt-1)w(vt+1)
for i ← n − 3 downto 0 do
S.push(ri+1)
u ← {ri-1(1),ri-1(2)}−{ri-1(1),ri-1(2)}∩{ri(1),ri(2)}
v ← {ri(1),ri(2)}−{ri-1(1),ri-1(2)}∩{ri(1),ri(2)}
while S not empty and w(u) ≤ crit(S.top) do
S.pop()
ra ← S.top
cost(ri) ← cost(ra) + w(u)×(W(ri) − W(ra) + w(ra(1))w(ra(2)) − w(u)w(v))
while S not empty and f(crit(S.top)) > 0 do
S.pop()
rb ← S.top
crit(ri) = cost(ri)-cost(rb)) ⁄ (W(ri)-W(rb)-w(ri(1))w(ri(2))
while S not empty and crit(ri) ≤ crit(S.top) do
S.pop()
Algorithm Triangulation()
Initialize()
post-order list of the horizontal arcs:
rn-2,rn-3,··· ,r0
cost(rn-2) ← w(vt-1)w(vt)w(vt+1)
crit(rn-2) ← cost(rn−2) ⁄ (W(rn−2)-w(vt−1)w(vt+1)
for i ← n − 3 downto 0 do
S.push(ri+1)
P Q.push(ri+1)
if Bridge(ri) then
rp ← Left(ri)
rq ← right(ri)
cumucost(ri) ← cost(rp) + cost(rq)
cumuw(ri) ← W(rp) + W(rq) − w(rp(1))w(rp(2)) − w(rq(1))w(rq(2))
Merge(rp,rq)
u ← {ri-1(1),ri-1(2)}−{ri-1(1),ri-1(2)}∩{ri(1),ri(2)}
v ← {ri(1),ri(2)}−{ri-1(1),ri-1(2)}∩{ri(1),ri(2)}
rp ← P Q.max
while w(u) < crit(rp) do
S.delete(rp)
P Q.delete(rp)
cumucost(ri) ← cumucost(ri) − cost(rp) + cumucost(rp)
cumuw(ri) ← cumuw(ri) − W(rp) + w(rp(1))w(rp(2)) + cumuw(rp)
rp ← P Q.max
cost(ri) ← cumucost(ri) + w(u)(W(ri) − cumuw(ri) − w(u)w(v))
rp ← P Q.max
while f(crit(rp)) < 0 do
S.delete(rp)
P Q.delete(rp)
cumucost(ri) ← cumucost(ri) − cost(rp) + cumucost(rp)
cumuw(ri) ← cumuw(ri) − W(rp) + w(rp(1))w(rp(2)) + cumuw(rp)
rp ← P Q.max
crit(ri) ← cost(ri)-cumucost(ri) ⁄ W(ri)-cumuw(ri)-w(ri(1))w(ri(2))
rp ← P Q.max
while crit(ri) ≤ crit(rp) do
P Q.delete(rp)
rp ← P Q.max
Algorithm Triangulation() requires O(nlog m) time and O(n) space in the worst case.
188.100.196.116 (talk) 01:11, 31 January 2016 (UTC)
If you know of algorithms for these problems would you add them to the article?
Problem #1: When the product of several matrices ABCDE is square, its matrix trace Tr(ABCDE) can be computed faster than with a two step process of first computing the product of the matrices P=ABCDE and then computing the trace of that product Tr(P). This arises for two reasons:
Is there an efficient algorithm that simultaneously finds the cyclic permutation and order of matrix multiplications to most efficiently compute Tr(ABCDE)?
Problem #2: When the product of several matrices ABCDE is square, the matrix determinant det(I+ABCDE) can be computed. We can exploit cyclic permutations as before, using that det(I+ABCDE) = det(I+BCDEA) = det(I+CDEAB) = det(I+DEABC) = det(I+EABCD). Instead of the time savings with the last matrix multiplication that we had for the matrix trace, we have an extra cost, that of computing the determinant, which depends upon the matrix dimensions of whichever of I+ABCDE, I+BCDEA, I+CDEAB, I+DEABC, I+EABCD we are computing the determinant of in the last step. Is there an efficient algorithm that simultaneously finds the cyclic permutation and order of matrix multiplications to most efficiently compute det(I+ABCDE)? Leegrc (talk) 13:19, 28 January 2015 (UTC)
Hello fellow Wikipedians,
I have just modified one external link on Matrix chain multiplication. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).
Cheers.—InternetArchiveBot (Report bug) 15:40, 21 January 2018 (UTC)
Recently, the reference to the original Stanford article was removed. The removed reference contains proofs omitted in the published journal version. The journal version explicitly refers to the Stanford article for details as reference 9 (part 1) and reference 7 (part 2) respectively. That's why I prefer to keep the Stanford article as well.
On the other hand, though the Stanford article is complete, the typesetting of the journal is a lot better, so I prefer to keep the journal versions as well for readability. — Preceding unsigned comment added by R.J.C.vanHaaften (talk • contribs) 10:43, 28 July 2018 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.