📄 text10-5.htm
字号:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#3399FF" alink="#FF0066">
<div id="Layer1" style="position:absolute; width:711px; height:21px; z-index:1; top: 10px; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000; left: 26px"><b>|</b><font face="宋体" size="2"><a href="../text1/text1-0.htm">第一章</a></font><b>|</b><font face="宋体" size="2"><a href="../text2/text2-0.htm">第二章</a></font><b>|</b><font face="宋体" size="2"><a href="../text3/text3-0.htm">第三章</a></font><b>|</b><font face="宋体" size="2"><a href="../text4/text4-0.htm">第四章</a></font><b>|</b><font face="宋体" size="2"><a href="../text5/text5-0.htm">第五章</a></font><b>|</b><font face="宋体" size="2"><a href="../text6/text6-0.htm">第六章</a></font><b>|</b><font face="宋体" size="2"><a href="../text7/text7-0.htm">第七章</a></font><b>|</b><font face="宋体" size="2"><a href="../text8/text8-0.htm">第八章</a></font><b>|</b><font face="宋体" size="2"><a href="../text9/text9-0.htm">第九章</a></font><b>|</b><font face="宋体" size="2">第十章</font><b>|</b><font size="2" face="宋体"><a href="../textA/textA-0.htm">算法分析</a><b><font color="#000000">|</font></b>
</font></div>
<pre align="left"><font face="Arial, Helvetica, sans-serif" size="4" color="#000000"><b>
〖<font color="#FF0000">example</font>〗
n = 4 and (<i>a1,a2,a3,a4 </i>) = (do, for, void, while )
<i> (p1, p2, p3, p4) = (3, 3, 1, 1)
(q0, q1, q2, q3, q4 ) = ( 2, 3, 1, 1, 1 )
wi,i = qi, c ii = 0, r ii = 0, 0 <= i <= 4</i>
</b></font><font face="Arial, Helvetica, sans-serif" size="4" color="#000000"><b><font size="2"><i> w01 = p1 + w00 + w11 = p1 + q1 +w00 = 8
c01 = w01 + min { c00 + c11 } = 8
r01 = 1
w12 = p2 + w11 + w22 = p2 + q2 +w11 = 7
c12 = w12 + min { c22 + c11 } = 7
r12 = 2
w23 = p3 + w22 + w33 = p3 + q3 +w22 = 3
c23 = w23 + min { c22 + c33 } = 3
r23 = 3
w34 = p4 + w33 + w44 = p4 + q4 +w33 = 3
c34 = w34 + min { c33 + c44 } = 3
r34 = 4</i></font>
<img src="image/text10-c.gif" width="325" height="237">
C04 = 32 is the minimal cost of a binary search tree for a1 to a4
<img src="image/text10-d.gif" width="233" height="93">
compute <i>cij </i> for ( j - i ) = 1, 2, …, n in that order,
compute each such <i>cij </i>in <font color="#FF0000">O<font color="#000000">(m)</font></font>
the total time for all <i>cij</i> 's with <i>j - i = m</i> is<font color="#FF0000"> O<font color="#000000">(nm -<img src="image/m2.gif" width="27" height="20" align="bottom"> )</font></font>
the total time to evaluate all the <i>cij</i> 's and <i>rij '</i>s is :
<font color="#FF0000"> <font color="#000000"> <img src="image/sum.gif" width="22" height="48" align="middle">(nm - <img src="image/m2.gif" width="27" height="20" align="bottom"> )</font> = O <font color="#000000">(<img src="image/n3.gif" width="21" height="20" align="bottom"> )</font></font></b></font></pre>
<p> </p>
<table width="731" cellspacing="0" cellpadding="0">
<tr>
<td width="327"> </td>
<td width="271"><a href="../index.htm"><img width="60" height="25" usemap="#MapMap4" border="0" src="../../images/home.gif"></a><a href="../index.htm"><map name="MapMap4"><area shape="rect" coords="42,-34,88,-15" href="text0.htm"><area shape="rect" coords="4,4,55,23" href="text10-index.htm"></map></a></td>
<td width="131"><font face="楷体_GB2312" size="2"><b><a href="text10-4.htm">上一页</a>
<a href="text10-6.htm">下一页</a> </b></font></td>
</tr>
</table>
<p> </p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -