tag:blogger.com,1999:blog-6198383970388980112024-03-12T17:09:35.004-07:00Solution ManualAccess to bulk amount of Study Resources, Course Notes, Test Prep, 24/7 Homework Help, solution manuals, homework help and more.Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.comBlogger771125tag:blogger.com,1999:blog-619838397038898011.post-64917147597678449232017-08-25T07:32:00.001-07:002017-08-25T07:52:02.534-07:00Chapter 3 Exercise 3.1-3, Introduction to Algorithms, 3rd Edition Thomas H. Cormen <div dir="ltr" style="text-align: left;" trbidi="on">
<b>3.1-3</b> Explain why the statement, “The running time of algorithm <b><i>A</i></b> is at \[O(n^2)\] <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>O</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>2</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-1-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr></nobr></span>,” is meaningless.<br />
<br />
<b>Solution: </b>Let us assume the running time of the algorithm is <b><i>T(n)</i></b>. Now, by definition, O-notation gives an upper bound for growth of functions but it doesn’t specifies the order of growth. Therefore, saying $$T(n) \ge O(n^2)$$ means growth of <i><b>T(n)</b></i> is greater than some upper bound which is meaningless as we do not have any idea about what we are comparing it with.<br />
<br />
For example, $$f(n) = 0$$ is $$O(n^2)$$ for all n. So, $$T(n) \ge f(n)$$ doesn’t tell us anything new as all running times are non-negative.</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-60808509239093336192017-08-25T07:28:00.000-07:002017-08-25T07:28:56.386-07:00Chapter 3 Exercise 3.1-2, Introduction to Algorithms, 3rd Edition Thomas H. Cormen <div dir="ltr" style="text-align: left;" trbidi="on">
<b>3.1-2 </b>Show that for any real constants <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi></math>" id="MathJax-Element-1-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-1" style="display: inline-block; width: 0.735em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 0.518em;"><span style="clip: rect(1.888em, 1000.49em, 2.598em, -1000em); left: 0em; position: absolute; top: -2.459em;"><span class="mrow" id="MathJax-Span-2"><span class="mi" id="MathJax-Span-3" style="font-family: "mathjax_math"; font-style: italic;">a</span></span></span></span></span></nobr></span> and <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi></math>" id="MathJax-Element-2-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-4" style="display: inline-block; width: 0.606em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 0.431em;"><span style="clip: rect(1.635em, 1000.42em, 2.599em, -1000em); left: 0em; position: absolute; top: -2.459em;"><span class="mrow" id="MathJax-Span-5"><span class="mi" id="MathJax-Span-6" style="font-family: "mathjax_math"; font-style: italic;">b</span></span></span></span></span></nobr></span>, where<br />
$$b > 0 , (n + a)^b =\Theta(n^b)$$<br />
<br />
<b>Solution:</b><br />
To prove this, we have to show that there exists constants $$c_1, c_2, n_0 > 0$$ such that $$0 \le c_1 n^b \le (n + a)^b \le c_2 n^b$$ for all $$n \ge n_0$$<br />
Note that, $$n + a \le 2n ,$$ when $$|a| \le n$$ Also note, $$n + a \ge \frac 1 2 n ,$$ when $$|a| \le \frac n 2$$ <br />
Therefore, when $$n \ge 2 \vert a \vert ,$$ $$0 \le \frac n 2 \le n + a \le 2n$$<br />
As b>0, we can raise all the terms of the previous inequality to the power of b without breaking the inequality: <br />
$$\begin {align}<br />
0 \le (\frac n 2)^b & \le (n + a)^b \le (2n)^b \\<br />
\Rightarrow 0 \le \frac 1 {2^b}n^b & \le (n + a)^b \le 2^bn^b<br />
\end {align}$$<br />
So,$$(n + a)^b = \Theta(n^b)$$ because there exists $$c_1 = 1/{2^b},c_2 = 2^b , $$ and $$n_0 = 2 \vert a \vert$$</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-83096552491747103122017-06-08T05:44:00.002-07:002017-08-18T07:51:10.175-07:00Chapter 3 Exercise 3.1-1, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
3.1-1 Let f(n) and g(n) be asymptotically non-negative functions. Using the basic definition of Θ-notation, prove that max(f(n),g(n))=Θ(f(n)+g(n)).<br />
<br />
<b>Solution:</b><br />
<br />
To prove this, we have to show that there exists constants $$c_1, c_2, n_0 > 0$$ such that $$0 \le c_1 (f(n) + g(n)) \le \max(f(n), g(n)) \le c_2 (f(n) + g(n))$$ for all $$n \ge n_0$$. As the functions are asymptotically non-negative, we can assume that for some $$n_0 > 0, f(n) \ge 0$$ and $$g(n) \ge 0$$.<span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mo>&#x2265;</mo><msub><mi>n</mi><mn>0</mn></msub></math>" id="MathJax-Element-11-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-134" style="display: inline-block; width: 3.899em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.922em;"><span style="clip: rect(1.853em, 1002.92em, 2.979em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-135"><span class="mi" id="MathJax-Span-136" style="font-family: "mathjax_math"; font-style: italic;"> </span></span></span></span></span></nobr></span><br />
So Far <br />
$$n \ge n_0$$ , $$f(n) + g(n) \ge \max(f(n), g(n))$$<br />
Also note that,<br />
$$f(n) \le \max(f(n), g(n))$$<br />
and $$g(n) \le \max(f(n), g(n)) \\<br />
\therefore f(n) + g(n) \le 2 \max(f(n), g(n)) \\<br />
\Rightarrow \frac 1 2 (f(n) + g(n)) \le \max(f(n), g(n))$$<br />
Therefore, we can combine the above two inequalities as follows:<br />
$$0 \le \frac 1 2 (f(n) + g(n)) \le \max(f(n), g(n)) \le (f(n) + g(n)) \text { for } n \ge n_0$$<br />
So, $$\max(f(n), g(n)) = \Theta(f(n) + g(n))$$ because there exists $$c_1 = \frac 1 2$$ and $$c_2 = 1$$</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-45475187442691620732017-05-25T03:44:00.003-07:002017-05-25T03:44:55.881-07:00Chapter 2 4 Problem, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<b>2-4 Inversions</b><br />
<br />
Let <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>A</mi><mo stretchy="false">[</mo><mn>1</mn><mo>.</mo><mo>.</mo><mi>n</mi><mo stretchy="false">]</mo></math>" id="MathJax-Element-1-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-1" style="display: inline-block; width: 4.488em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 3.235em;"><span style="clip: rect(1.795em, 1003.12em, 3.054em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-2"><span class="mi" id="MathJax-Span-3" style="font-family: "mathjax_math"; font-style: italic;">A</span><span class="mo" id="MathJax-Span-4" style="font-family: "mathjax_main";">[</span><span class="mn" id="MathJax-Span-5" style="font-family: "mathjax_main";">1</span><span class="mo" id="MathJax-Span-6" style="font-family: "mathjax_main";">.</span><span class="mo" id="MathJax-Span-7" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mi" id="MathJax-Span-8" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span><span class="mo" id="MathJax-Span-9" style="font-family: "mathjax_main";">]</span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.499em; overflow: hidden; vertical-align: -0.405em; width: 0px;"></span></span></nobr></span> be an array of <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi></math>" id="MathJax-Element-2-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-10" style="display: inline-block; width: 0.865em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 0.604em;"><span style="clip: rect(1.887em, 1000.58em, 2.599em, -1000em); left: 0em; position: absolute; top: -2.459em;"><span class="mrow" id="MathJax-Span-11"><span class="mi" id="MathJax-Span-12" style="font-family: "mathjax_math"; font-style: italic;">n</span></span><span style="display: inline-block; height: 2.459em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 0.744em; overflow: hidden; vertical-align: -0.075em; width: 0px;"></span></span></nobr></span> distinct numbers. If <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mo>&lt;</mo><mi>j</mi></math>" id="MathJax-Element-3-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-13" style="display: inline-block; width: 2.935em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 2.114em;"><span style="clip: rect(1.884em, 1002.1em, 3.008em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-14"><span class="mi" id="MathJax-Span-15" style="font-family: "mathjax_math"; font-style: italic;">i</span><span class="mo" id="MathJax-Span-16" style="font-family: "mathjax_main"; padding-left: 0.278em;"><</span><span class="mi" id="MathJax-Span-17" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.278em;">j</span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.313em; overflow: hidden; vertical-align: -0.341em; width: 0px;"></span></span></nobr></span> and <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>A</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo><mo>&gt;</mo><mi>A</mi><mo stretchy="false">[</mo><mi>j</mi><mo stretchy="false">]</mo></math>" id="MathJax-Element-4-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-18" style="display: inline-block; width: 6.386em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 4.615em;"><span style="clip: rect(1.795em, 1004.5em, 3.054em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-19"><span class="mi" id="MathJax-Span-20" style="font-family: "mathjax_math"; font-style: italic;">A</span><span class="mo" id="MathJax-Span-21" style="font-family: "mathjax_main";">[</span><span class="mi" id="MathJax-Span-22" style="font-family: "mathjax_math"; font-style: italic;">i</span><span class="mo" id="MathJax-Span-23" style="font-family: "mathjax_main";">]</span><span class="mo" id="MathJax-Span-24" style="font-family: "mathjax_main"; padding-left: 0.278em;">></span><span class="mi" id="MathJax-Span-25" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.278em;">A</span><span class="mo" id="MathJax-Span-26" style="font-family: "mathjax_main";">[</span><span class="mi" id="MathJax-Span-27" style="font-family: "mathjax_math"; font-style: italic;">j</span><span class="mo" id="MathJax-Span-28" style="font-family: "mathjax_main";">]</span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.499em; overflow: hidden; vertical-align: -0.405em; width: 0px;"></span></span></nobr></span>, then the pair <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mo stretchy="false">(</mo><mi>i</mi><mo>,</mo><mi>j</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-5-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-29" style="display: inline-block; width: 2.763em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 1.984em;"><span style="clip: rect(1.795em, 1001.89em, 3.054em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-30"><span class="mo" id="MathJax-Span-31" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-32" style="font-family: "mathjax_math"; font-style: italic;">i</span><span class="mo" id="MathJax-Span-33" style="font-family: "mathjax_main";">,</span><span class="mi" id="MathJax-Span-34" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">j</span><span class="mo" id="MathJax-Span-35" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.499em; overflow: hidden; vertical-align: -0.405em; width: 0px;"></span></span></nobr></span> is called an <b><i>inversion</i></b> of <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>A</mi></math>" id="MathJax-Element-6-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-36" style="display: inline-block; width: 1.037em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 0.733em;"><span style="clip: rect(1.613em, 1000.71em, 2.588em, -1000em); left: 0em; position: absolute; top: -2.459em;"><span class="mrow" id="MathJax-Span-37"><span class="mi" id="MathJax-Span-38" style="font-family: "mathjax_math"; font-style: italic;">A</span></span><span style="display: inline-block; height: 2.459em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.107em; overflow: hidden; vertical-align: -0.06em; width: 0px;"></span></span></nobr></span>.<br />
<br />
<ol style="text-align: left;">
<li>List the five inversions of the array <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mo fence="false" stretchy="false">&#x27E8;</mo><mn>2</mn><mo>,</mo><mn>3</mn><mo>,</mo><mn>8</mn><mo>,</mo><mn>6</mn><mo>,</mo><mn>1</mn><mo fence="false" stretchy="false">&#x27E9;</mo></math>" id="MathJax-Element-7-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-39" style="display: inline-block; width: 6.99em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 5.047em;"><span style="clip: rect(1.795em, 1004.94em, 3.054em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-40"><span class="mo" id="MathJax-Span-41" style="font-family: "mathjax_main";">⟨</span><span class="mn" id="MathJax-Span-42" style="font-family: "mathjax_main";">2</span><span class="mo" id="MathJax-Span-43" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-44" style="font-family: "mathjax_main"; padding-left: 0.167em;">3</span><span class="mo" id="MathJax-Span-45" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-46" style="font-family: "mathjax_main"; padding-left: 0.167em;">8</span><span class="mo" id="MathJax-Span-47" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-48" style="font-family: "mathjax_main"; padding-left: 0.167em;">6</span><span class="mo" id="MathJax-Span-49" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-50" style="font-family: "mathjax_main"; padding-left: 0.167em;">1</span><span class="mo" id="MathJax-Span-51" style="font-family: "mathjax_main";">⟩</span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.499em; overflow: hidden; vertical-align: -0.405em; width: 0px;"></span></span></nobr></span>. </li>
<li>What array with elements from the set <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow class="MJX-TeXAtom-ORD"><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mo>&#x2026;</mo><mo>,</mo><mi>n</mi></mrow></math>" id="MathJax-Element-8-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-52" style="display: inline-block; width: 5.868em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 4.227em;"><span style="clip: rect(1.879em, 1004.21em, 2.998em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-53"><span class="texatom" id="MathJax-Span-54"><span class="mrow" id="MathJax-Span-55"><span class="mn" id="MathJax-Span-56" style="font-family: "mathjax_main";">1</span><span class="mo" id="MathJax-Span-57" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-58" style="font-family: "mathjax_main"; padding-left: 0.167em;">2</span><span class="mo" id="MathJax-Span-59" style="font-family: "mathjax_main";">,</span><span class="mo" id="MathJax-Span-60" style="font-family: "mathjax_main"; padding-left: 0.167em;">…</span><span class="mo" id="MathJax-Span-61" style="font-family: "mathjax_main"; padding-left: 0.167em;">,</span><span class="mi" id="MathJax-Span-62" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span></span></span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.306em; overflow: hidden; vertical-align: -0.327em; width: 0px;"></span></span></nobr></span> has the most inversions? How many does it have? </li>
<li>What is the relationship between the running time of insertion sort and
the number of inversions in the input array? Justify your answer. </li>
<li>Give an algorithm that determines the number of inversions in any permutation on <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi></math>" id="MathJax-Element-9-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-63" style="display: inline-block; width: 0.865em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 0.604em;"><span style="clip: rect(1.887em, 1000.58em, 2.599em, -1000em); left: 0em; position: absolute; top: -2.459em;"><span class="mrow" id="MathJax-Span-64"><span class="mi" id="MathJax-Span-65" style="font-family: "mathjax_math"; font-style: italic;">n</span></span><span style="display: inline-block; height: 2.459em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 0.744em; overflow: hidden; vertical-align: -0.075em; width: 0px;"></span></span></nobr></span> elements in <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0398;</mi><mo stretchy="false">(</mo><mi>n</mi><mi>lg</mi><mo>&#x2061;</mo><mi>n</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-66" style="display: inline-block; width: 5.394em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 3.882em;"><span style="clip: rect(1.795em, 1003.79em, 3.054em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-67"><span class="mi" id="MathJax-Span-68" style="font-family: "mathjax_main";">Θ</span><span class="mo" id="MathJax-Span-69" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-70" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mi" id="MathJax-Span-71" style="font-family: "mathjax_main"; padding-left: 0.167em;">lg</span><span class="mo" id="MathJax-Span-72"></span><span class="mi" id="MathJax-Span-73" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span><span class="mo" id="MathJax-Span-74" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.499em; overflow: hidden; vertical-align: -0.405em; width: 0px;"></span></span></nobr></span> worst-case time. (<i>Hint:</i> Modify merge sort.)</li>
</ol>
<b>1. List of Inversions</b><br />
Inversions in the given array are: (1, 5), (2, 5), (3, 4), (3, 5), and (4, 5). (<i>Note:</i> Inversions are specified by indices of the array, not by values.)<br />
<br />
<b>2. Array With Most Inversions</b>
<br />
The array with elements from the set <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow class="MJX-TeXAtom-ORD"><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mo>&#x2026;</mo><mo>,</mo><mi>n</mi></mrow></math>" id="MathJax-Element-11-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-75" style="display: inline-block; width: 5.576em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 4.221em;"><span style="clip: rect(1.823em, 1004.2em, 3.008em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-76"><span class="texatom" id="MathJax-Span-77"><span class="mrow" id="MathJax-Span-78"><span class="mn" id="MathJax-Span-79" style="font-family: "mathjax_main";">1</span><span class="mo" id="MathJax-Span-80" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-81" style="font-family: "mathjax_main"; padding-left: 0.167em;">2</span><span class="mo" id="MathJax-Span-82" style="font-family: "mathjax_main";">,</span><span class="mo" id="MathJax-Span-83" style="font-family: "mathjax_main"; padding-left: 0.167em;">…</span><span class="mo" id="MathJax-Span-84" style="font-family: "mathjax_main"; padding-left: 0.167em;">,</span><span class="mi" id="MathJax-Span-85" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span></span></span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.278em; overflow: hidden; vertical-align: -0.328em; width: 0px;"></span></span></nobr></span><br />
with the most inversions will have the elements in reverse sorted order, i.e. <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mo fence="false" stretchy="false">&#x27E8;</mo><mi>n</mi><mo>,</mo><mi>n</mi><mo>&#x2212;</mo><mn>1</mn><mo>,</mo><mo>&#x2026;</mo><mo>,</mo><mn>2</mn><mo>,</mo><mn>1</mn><mo fence="false" stretchy="false">&#x27E9;</mo></math>" id="MathJax-Element-12-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-86" style="display: inline-block; width: 10.23em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 7.738em;"><span style="clip: rect(1.739em, 1007.63em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-87"><span class="mo" id="MathJax-Span-88" style="font-family: "mathjax_main";">⟨</span><span class="mi" id="MathJax-Span-89" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mo" id="MathJax-Span-90" style="font-family: "mathjax_main";">,</span><span class="mi" id="MathJax-Span-91" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span><span class="mo" id="MathJax-Span-92" style="font-family: "mathjax_main"; padding-left: 0.222em;">−</span><span class="mn" id="MathJax-Span-93" style="font-family: "mathjax_main"; padding-left: 0.222em;">1</span><span class="mo" id="MathJax-Span-94" style="font-family: "mathjax_main";">,</span><span class="mo" id="MathJax-Span-95" style="font-family: "mathjax_main"; padding-left: 0.167em;">…</span><span class="mo" id="MathJax-Span-96" style="font-family: "mathjax_main"; padding-left: 0.167em;">,</span><span class="mn" id="MathJax-Span-97" style="font-family: "mathjax_main"; padding-left: 0.167em;">2</span><span class="mo" id="MathJax-Span-98" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-99" style="font-family: "mathjax_main"; padding-left: 0.167em;">1</span><span class="mo" id="MathJax-Span-100" style="font-family: "mathjax_main";">⟩</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.463em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span>.<br />
<br />
As the array has <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi></math>" id="MathJax-Element-13-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-101" style="display: inline-block; width: 0.814em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.595em;"><span style="clip: rect(1.831em, 1000.58em, 2.608em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-102"><span class="mi" id="MathJax-Span-103" style="font-family: "mathjax_math"; font-style: italic;">n</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 0.741em; overflow: hidden; vertical-align: -0.086em; width: 0px;"></span></span></nobr></span> unique elements in reverse sorted order, for every unique pair of <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mo stretchy="false">(</mo><mi>i</mi><mo>,</mo><mi>j</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-14-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-104" style="display: inline-block; width: 2.6em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 1.948em;"><span style="clip: rect(1.739em, 1001.85em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-105"><span class="mo" id="MathJax-Span-106" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-107" style="font-family: "mathjax_math"; font-style: italic;">i</span><span class="mo" id="MathJax-Span-108" style="font-family: "mathjax_main";">,</span><span class="mi" id="MathJax-Span-109" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">j</span><span class="mo" id="MathJax-Span-110" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.463em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span>, there will be an inversion. So, total number of inversion = number of ways to choose 2 distinct integer from the set <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow class="MJX-TeXAtom-ORD"><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mo>&#x2026;</mo><mo>,</mo><mi>n</mi></mrow></math>" id="MathJax-Element-15-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-111" style="display: inline-block; width: 5.576em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 4.221em;"><span style="clip: rect(1.823em, 1004.2em, 3.008em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-112"><span class="texatom" id="MathJax-Span-113"><span class="mrow" id="MathJax-Span-114"><span class="mn" id="MathJax-Span-115" style="font-family: "mathjax_main";">1</span><span class="mo" id="MathJax-Span-116" style="font-family: "mathjax_main";">,</span><span class="mn" id="MathJax-Span-117" style="font-family: "mathjax_main"; padding-left: 0.167em;">2</span><span class="mo" id="MathJax-Span-118" style="font-family: "mathjax_main";">,</span><span class="mo" id="MathJax-Span-119" style="font-family: "mathjax_main"; padding-left: 0.167em;">…</span><span class="mo" id="MathJax-Span-120" style="font-family: "mathjax_main"; padding-left: 0.167em;">,</span><span class="mi" id="MathJax-Span-121" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span></span></span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.278em; overflow: hidden; vertical-align: -0.328em; width: 0px;"></span></span></nobr></span> = <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mrow class="MJX-TeXAtom-OPEN"><mo maxsize="1.2em" minsize="1.2em">(</mo></mrow><mfrac linethickness="0"><mi>n</mi><mn>2</mn></mfrac><mrow class="MJX-TeXAtom-CLOSE"><mo maxsize="1.2em" minsize="1.2em">)</mo></mrow></mrow></math>" id="MathJax-Element-16-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-122" style="display: inline-block; width: 1.734em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 1.299em;"><span style="clip: rect(1.694em, 1001.15em, 3.217em, -1000em); left: 0em; position: absolute; top: -2.706em;"><span class="mrow" id="MathJax-Span-123"><span class="mrow" id="MathJax-Span-124"><span class="TeXmathchoice" id="MathJax-Span-125"><span class="texatom" id="MathJax-Span-126"><span class="mrow" id="MathJax-Span-127"><span class="mo" id="MathJax-Span-128" style="vertical-align: 0em;"><span style="font-family: "mathjax_size1";">(</span></span></span></span></span><span class="mfrac" id="MathJax-Span-129"><span style="display: inline-block; height: 0px; position: relative; width: 0.424em;"><span style="clip: rect(3.529em, 1000.41em, 4.174em, -1000em); left: 50%; margin-left: -0.212em; position: absolute; top: -4.448em;"><span class="mi" id="MathJax-Span-130" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.371em, 1000.32em, 4.167em, -1000em); left: 50%; margin-left: -0.177em; position: absolute; top: -3.659em;"><span class="mn" id="MathJax-Span-131" style="font-family: "mathjax_main"; font-size: 70.7%;">2</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="TeXmathchoice" id="MathJax-Span-132"><span class="texatom" id="MathJax-Span-133"><span class="mrow" id="MathJax-Span-134"><span class="mo" id="MathJax-Span-135" style="vertical-align: 0em;"><span style="font-family: "mathjax_size1";">)</span></span></span></span></span></span></span><span style="display: inline-block; height: 2.706em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.726em; overflow: hidden; vertical-align: -0.533em; width: 0px;"></span></span></nobr></span> = <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mrow><mi>n</mi><mo stretchy="false">(</mo><mi>n</mi><mo>&#x2212;</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><mn>2</mn></mfrac></math>" id="MathJax-Element-17-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-136" style="display: inline-block; width: 3.52em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.652em;"><span style="clip: rect(0.938em, 1002.65em, 2.763em, -1000em); left: 0em; position: absolute; top: -2.219em;"><span class="mrow" id="MathJax-Span-137"><span class="mfrac" id="MathJax-Span-138"><span style="display: inline-block; height: 0px; margin-left: 0.12em; margin-right: 0.12em; position: relative; width: 2.422em;"><span style="clip: rect(3.312em, 1002.23em, 4.343em, -1000em); left: 50%; margin-left: -1.151em; position: absolute; top: -4.593em;"><span class="mrow" id="MathJax-Span-139"><span class="mi" id="MathJax-Span-140" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-141" style="font-family: "mathjax_main"; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-142" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-143" style="font-family: "mathjax_main"; font-size: 70.7%;">−</span><span class="mn" id="MathJax-Span-144" style="font-family: "mathjax_main"; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-145" style="font-family: "mathjax_main"; font-size: 70.7%;">)</span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.371em, 1000.32em, 4.167em, -1000em); left: 50%; margin-left: -0.177em; position: absolute; top: -3.622em;"><span class="mn" id="MathJax-Span-146" style="font-family: "mathjax_main"; font-size: 70.7%;">2</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(0.852em, 1002.42em, 1.245em, -1000em); left: 0em; position: absolute; top: -1.302em;"><span style="border-top: 1.3px solid; display: inline-block; height: 0px; overflow: hidden; vertical-align: 0em; width: 2.422em;"></span><span style="display: inline-block; height: 1.082em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.219em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 2.124em; overflow: hidden; vertical-align: -0.576em; width: 0px;"></span></span></nobr></span>.<br />
<br />
<b>3. Relationship With Insertion Sort</b>
<br />
If we take look at the pseudocode for insertion sort with the
definition of inversions in mind, we will realize that the more the
number of inversions in an array, the more times the inner <b>while</b>
loop will run. The reason being more inversions means most of the array
is reverse sorted, i.e. more swaps to perform in the while loop.<br />
So, the higher the number of inversions in an array, the longer insertion sort will take to sort the array.<br />
<br />
<b>4. Algorithm to Calculate Inversions</b>
<br />
Although a hint to modify merge sort is already given, without that
also we should think of divide-and-conquer algorithms whenever we see
running time of <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0398;</mi><mo stretchy="false">(</mo><mi>lg</mi><mo>&#x2061;</mo><mi>n</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-18-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-147" style="display: inline-block; width: 4.007em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 3.03em;"><span style="clip: rect(1.739em, 1002.93em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-148"><span class="mi" id="MathJax-Span-149" style="font-family: "mathjax_main";">Θ</span><span class="mo" id="MathJax-Span-150" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-151" style="font-family: "mathjax_main";">lg</span><span class="mo" id="MathJax-Span-152"></span><span class="mi" id="MathJax-Span-153" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span><span class="mo" id="MathJax-Span-154" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span></span></nobr></span>.<br />
<br />
As was done in merge sort, we need to recursively divide the array
into halfs and count number of inversions in the sub-arrays. This will
result in <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>lg</mi><mo>&#x2061;</mo><mi>n</mi></math>" id="MathJax-Element-19-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-155" style="display: inline-block; width: 2.005em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 1.515em;"><span style="clip: rect(1.795em, 1001.49em, 3.02em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-156"><span class="mi" id="MathJax-Span-157" style="font-family: "mathjax_main";">lg</span><span class="mo" id="MathJax-Span-158"></span><span class="mi" id="MathJax-Span-159" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.331em; overflow: hidden; vertical-align: -0.343em; width: 0px;"></span></span></nobr></span><br />
steps and <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0398;</mi><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-20-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-160" style="display: inline-block; width: 2.817em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.11em;"><span style="clip: rect(1.739em, 1002.02em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-161"><span class="mi" id="MathJax-Span-162" style="font-family: "mathjax_main";">Θ</span><span class="mo" id="MathJax-Span-163" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-164" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mo" id="MathJax-Span-165" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.463em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span> operations in each step to count the inversions. All in all a <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0398;</mi><mo stretchy="false">(</mo><mi>n</mi><mi>lg</mi><mo>&#x2061;</mo><mi>n</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-21-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-166" style="display: inline-block; width: 5.035em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 3.788em;"><span style="clip: rect(1.739em, 1003.69em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-167"><span class="mi" id="MathJax-Span-168" style="font-family: "mathjax_main";">Θ</span><span class="mo" id="MathJax-Span-169" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-170" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mi" id="MathJax-Span-171" style="font-family: "mathjax_main"; padding-left: 0.167em;">lg</span><span class="mo" id="MathJax-Span-172"></span><span class="mi" id="MathJax-Span-173" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">n</span><span class="mo" id="MathJax-Span-174" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.463em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span> algorithm.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">def</span> <span style="color: #0066bb; font-weight: bold;">merge</span>(items, p, q, r):
L <span style="color: #333333;">=</span> items[p:q<span style="color: #333333;">+</span><span style="color: #0000dd; font-weight: bold;">1</span>]
R <span style="color: #333333;">=</span> items[q<span style="color: #333333;">+</span><span style="color: #0000dd; font-weight: bold;">1</span>:r<span style="color: #333333;">+</span><span style="color: #0000dd; font-weight: bold;">1</span>]
i <span style="color: #333333;">=</span> j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
k <span style="color: #333333;">=</span> p
inversions <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">while</span> i <span style="color: #333333;"><</span> <span style="color: #007020;">len</span>(L) <span style="color: black; font-weight: bold;">and</span> j <span style="color: #333333;"><</span> <span style="color: #007020;">len</span>(R):
<span style="color: #008800; font-weight: bold;">if</span>(L[i] <span style="color: #333333;"><</span> R[j]):
items[k] <span style="color: #333333;">=</span> L[i]
i <span style="color: #333333;">+=</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">else</span>:
items[k] <span style="color: #333333;">=</span> R[j]
j <span style="color: #333333;">+=</span> <span style="color: #0000dd; font-weight: bold;">1</span>
inversions <span style="color: #333333;">+=</span> (<span style="color: #007020;">len</span>(L) <span style="color: #333333;">-</span> i)
k <span style="color: #333333;">+=</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">if</span>(j <span style="color: #333333;">==</span> <span style="color: #007020;">len</span>(R)):
items[k:r<span style="color: #333333;">+</span><span style="color: #0000dd; font-weight: bold;">1</span>] <span style="color: #333333;">=</span> L[i:]
<span style="color: #008800; font-weight: bold;">return</span> inversions
<span style="color: #008800; font-weight: bold;">def</span> <span style="color: #0066bb; font-weight: bold;">mergesort</span>(items, p, r):
inversions <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">if</span>(p <span style="color: #333333;"><</span> r):
q <span style="color: #333333;">=</span> (p<span style="color: #333333;">+</span>r)<span style="color: #333333;">/</span><span style="color: #0000dd; font-weight: bold;">2</span>
inversions <span style="color: #333333;">+=</span> mergesort(items, p, q)
inversions <span style="color: #333333;">+=</span> mergesort(items, q<span style="color: #333333;">+</span><span style="color: #0000dd; font-weight: bold;">1</span>, r)
inversions <span style="color: #333333;">+=</span> merge(items, p, q, r)
<span style="color: #008800; font-weight: bold;">return</span> inversions
items <span style="color: #333333;">=</span> [<span style="color: #0000dd; font-weight: bold;">4</span>,<span style="color: #0000dd; font-weight: bold;">3</span>,<span style="color: #0000dd; font-weight: bold;">2</span>,<span style="color: #0000dd; font-weight: bold;">1</span>,<span style="color: #0000dd; font-weight: bold;">17</span>]
inversions <span style="color: #333333;">=</span> mergesort(items, <span style="color: #0000dd; font-weight: bold;">0</span>, <span style="color: #007020;">len</span>(items)<span style="color: #333333;">-</span><span style="color: #0000dd; font-weight: bold;">1</span>)
<span style="color: #008800; font-weight: bold;">print</span> items,inversions
</pre>
</div>
<br />
<br /></div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-77178922205963661252017-05-25T03:36:00.005-07:002017-05-25T03:36:56.226-07:00Chapter 2 3 Problem, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<b>2-3 Correctness of Horner’s rule</b><br />
<br />
The following code fragment implements Horner’s rule for evaluating a polynomial<br />
$$ \begin {align}
P(x) & = \sum _{k = 0}^n a_k x^k \\
& = a_0 + x(a_1 + x(a_2 +· · · + x(a_{n − 1} + xa_n) · · ·))
\end {align} $$
<br />
<br />
given the coefficients a 0 ; a 1 ; : : : ; a n and a value for x:<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">y <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">for</span> i <span style="color: #333333;">=</span> n downto <span style="color: #0000dd; font-weight: bold;">0</span>
y <span style="color: #333333;">=</span> a_i <span style="color: #333333;">+</span> x <span style="color: #333333;">*</span> y
</pre>
</div>
<br />
<ol style="text-align: left;">
<li>In terms of Θ-notation, what is the asymptotic running time of this code fragment for Horner’s rule? </li>
<li>Write pseudocode to implement the naive polynomial-evaluation algorithm that computes each term of the polynomial from scratch. What is the running time of this algorithm? How does it compare to Horner’s rule? </li>
<li>Consider the following loop invariant:.
At the start of each iteration of the for loop of lines 2-3,
<span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>y</mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup><mspace linebreak="newline" /></math>" id="MathJax-Element-5-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-97" style="display: inline-block; width: 13.115em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 9.486em;"><span style="clip: rect(2.83em, 1009.49em, 5.341em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mrow" id="MathJax-Span-98"><span style="display: inline-block; height: 0px; position: relative; width: 9.486em;"><span style="clip: rect(2.83em, 1009.49em, 4.483em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-99" style="font-family: "mathjax_math"; font-style: italic;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span><span class="mo" id="MathJax-Span-100" style="font-family: "mathjax_main"; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-101" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 3.803em;"><span style="clip: rect(3.132em, 1001em, 4.391em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mo" id="MathJax-Span-102" style="font-family: "mathjax_size1"; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="clip: rect(3.352em, 1002.75em, 4.318em, -1000em); left: 1.056em; position: absolute; top: -4.533em;"><span class="texatom" id="MathJax-Span-103"><span class="mrow" id="MathJax-Span-104"><span class="mi" id="MathJax-Span-105" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-106" style="font-family: "mathjax_main"; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-107" style="font-family: "mathjax_main"; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-108" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-109" style="font-family: "mathjax_main"; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-110" style="font-family: "mathjax_main"; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-111" style="font-family: "mathjax_main"; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="clip: rect(3.391em, 1001.35em, 4.156em, -1000em); left: 1.056em; position: absolute; top: -3.685em;"><span class="texatom" id="MathJax-Span-112"><span class="mrow" id="MathJax-Span-113"><span class="mi" id="MathJax-Span-114" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-115" style="font-family: "mathjax_main"; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-116" style="font-family: "mathjax_main"; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-117" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.441em, 1000.51em, 4.151em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-118" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.861em;"><span class="texatom" id="MathJax-Span-119"><span class="mrow" id="MathJax-Span-120"><span class="mi" id="MathJax-Span-121" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-122" style="font-family: "mathjax_main"; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-123" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-124" style="font-family: "mathjax_main"; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-125" style="font-family: "mathjax_main"; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-126"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.44em, 1000.52em, 4.152em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-127" style="font-family: "mathjax_math"; font-style: italic;">x</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.374em;"><span class="mi" id="MathJax-Span-128" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="clip: rect(3.882em, 1000em, 4.141em, -1000em); left: 0em; position: absolute; top: -2.811em;"><span class="mspace" id="MathJax-Span-129" style="display: inline-block; height: 0em; overflow: hidden; vertical-align: 0em; width: 0em;"></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 3.226em; overflow: hidden; vertical-align: -1.716em; width: 0px;"></span></span></nobr></span>
Interpret a summation with no terms as equaling 0. Your proof should
follow the structure of the loop invariant proof presented in this
chapter and should show that, at termination, <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>y</mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mi>n</mi></munderover><msub><mi>a</mi><mi>k</mi></msub><msup><mi>x</mi><mi>k</mi></msup></math>" id="MathJax-Element-6-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-130" style="display: inline-block; width: 8.844em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 6.384em;"><span style="clip: rect(1.691em, 1006.38em, 3.105em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-131"><span class="mi" id="MathJax-Span-132" style="font-family: "mathjax_math"; font-style: italic;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span><span class="mo" id="MathJax-Span-133" style="font-family: "mathjax_main"; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-134" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.403em;"><span style="clip: rect(3.132em, 1001em, 4.391em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mo" id="MathJax-Span-135" style="font-family: "mathjax_size1"; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="clip: rect(3.569em, 1000.5em, 4.149em, -1000em); left: 1.056em; position: absolute; top: -4.488em;"><span class="mi" id="MathJax-Span-136" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="clip: rect(3.391em, 1001.35em, 4.156em, -1000em); left: 1.056em; position: absolute; top: -3.726em;"><span class="texatom" id="MathJax-Span-137"><span class="mrow" id="MathJax-Span-138"><span class="mi" id="MathJax-Span-139" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-140" style="font-family: "mathjax_main"; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-141" style="font-family: "mathjax_main"; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-142" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.972em;"><span style="clip: rect(3.441em, 1000.51em, 4.151em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-143" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.861em;"><span class="mi" id="MathJax-Span-144" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-145"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.44em, 1000.52em, 4.152em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-146" style="font-family: "mathjax_math"; font-style: italic;">x</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.374em;"><span class="mi" id="MathJax-Span-147" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.712em; overflow: hidden; vertical-align: -0.475em; width: 0px;"></span></span></nobr></span>. </li>
<li> Conclude by arguing that the given code fragment correctly evaluates a polynomial characterized by the coefficients <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>a</mi><mn>0</mn></msub><mo>,</mo><msub><mi>a</mi><mn>1</mn></msub><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><msub><mi>a</mi><mi>n</mi></msub></math>" id="MathJax-Element-7-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-148" style="display: inline-block; width: 7.594em;"><span style="display: inline-block; font-size: 138%; height: 0px; position: relative; width: 5.478em;"><span style="clip: rect(2.104em, 1005.48em, 2.998em, -1000em); left: 0em; position: absolute; top: -2.674em;"><span class="mrow" id="MathJax-Span-149"><span class="msubsup" id="MathJax-Span-150"><span style="display: inline-block; height: 0px; position: relative; width: 0.958em;"><span style="clip: rect(3.441em, 1000.51em, 4.151em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-151" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.861em;"><span class="mn" id="MathJax-Span-152" style="font-family: "mathjax_main"; font-size: 70.7%;">0</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-153" style="font-family: "mathjax_main";">,</span><span class="msubsup" id="MathJax-Span-154" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.958em;"><span style="clip: rect(3.441em, 1000.51em, 4.151em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-155" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.861em;"><span class="mn" id="MathJax-Span-156" style="font-family: "mathjax_main"; font-size: 70.7%;">1</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-157" style="font-family: "mathjax_main";">,</span><span class="mo" id="MathJax-Span-158" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mo" id="MathJax-Span-159" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mo" id="MathJax-Span-160" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mo" id="MathJax-Span-161" style="font-family: "mathjax_main"; padding-left: 0.167em;">,</span><span class="msubsup" id="MathJax-Span-162" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 1.028em;"><span style="clip: rect(3.441em, 1000.51em, 4.151em, -1000em); left: 0em; position: absolute; top: -4.011em;"><span class="mi" id="MathJax-Span-163" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.861em;"><span class="mi" id="MathJax-Span-164" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span style="display: inline-block; height: 4.011em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.674em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 0.995em; overflow: hidden; vertical-align: -0.327em; width: 0px;"></span></span></nobr></span>.</li>
</ol>
<b>Solution:</b><br />
<br />
<b><b>1. Asymptotic Running Time</b></b><br />
<br />
From the pseudocode of Horner’s Rule, the algorithm runs in a loop for all the elements, i.e. it runs at <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0398;</mi><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></math>" id="MathJax-Element-8-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-165" style="display: inline-block; width: 2.817em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.11em;"><span style="clip: rect(1.739em, 1002.02em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-166"><span class="mi" id="MathJax-Span-167" style="font-family: "mathjax_main";">Θ</span><span class="mo" id="MathJax-Span-168" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-169" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mo" id="MathJax-Span-170" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.463em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span> time.<br />
<br />
<b>2. Comparison with Naive Algorithm</b><br />
<br />
Pseudocode for <code class="highlighter-rouge">NAIVE-POLY-EVAL(A, x)</code>, where <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>A</mi></math>" id="MathJax-Element-9-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-171" style="display: inline-block; width: 1.031em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.758em;"><span style="clip: rect(1.557em, 1000.73em, 2.597em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-172"><span class="mi" id="MathJax-Span-173" style="font-family: "mathjax_math"; font-style: italic;">A</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.088em; overflow: hidden; vertical-align: -0.071em; width: 0px;"></span></span></nobr></span> is the array of length <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mo>+</mo><mn>1</mn></math>" id="MathJax-Element-10-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-174" style="display: inline-block; width: 3.033em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.273em;"><span style="clip: rect(1.823em, 1002.2em, 2.896em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-175"><span class="mi" id="MathJax-Span-176" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mo" id="MathJax-Span-177" style="font-family: "mathjax_main"; padding-left: 0.222em;">+</span><span class="mn" id="MathJax-Span-178" style="font-family: "mathjax_main"; padding-left: 0.222em;">1</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.13em; overflow: hidden; vertical-align: -0.18em; width: 0px;"></span></span></nobr></span> consisting of the coefficients <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>a</mi><mn>0</mn></msub><mo>,</mo><msub><mi>a</mi><mn>1</mn></msub><mo>,</mo><mo>.</mo><mo>.</mo><mo>.</mo><mo>,</mo><msub><mi>a</mi><mi>n</mi></msub></math>" id="MathJax-Element-11-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-179" style="display: inline-block; width: 7.362em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 5.574em;"><span style="clip: rect(2.048em, 1005.57em, 3.008em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-180"><span class="msubsup" id="MathJax-Span-181"><span style="display: inline-block; height: 0px; position: relative; width: 0.958em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-182" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mn" id="MathJax-Span-183" style="font-family: "mathjax_main"; font-size: 70.7%;">0</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-184" style="font-family: "mathjax_main";">,</span><span class="msubsup" id="MathJax-Span-185" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.958em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-186" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mn" id="MathJax-Span-187" style="font-family: "mathjax_main"; font-size: 70.7%;">1</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-188" style="font-family: "mathjax_main";">,</span><span class="mo" id="MathJax-Span-189" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mo" id="MathJax-Span-190" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mo" id="MathJax-Span-191" style="font-family: "mathjax_main"; padding-left: 0.167em;">.</span><span class="mo" id="MathJax-Span-192" style="font-family: "mathjax_main"; padding-left: 0.167em;">,</span><span class="msubsup" id="MathJax-Span-193" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 1.028em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-194" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mi" id="MathJax-Span-195" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 0.981em; overflow: hidden; vertical-align: -0.328em; width: 0px;"></span></span></nobr></span>.<br />
<br />
<ol style="text-align: left;">
</ol>
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">y <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span>
<span style="color: #008800; font-weight: bold;">for</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to A<span style="color: #333333;">.</span>length
m <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">for</span> j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to i <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>
m <span style="color: #333333;">=</span> m <span style="color: #333333;">*</span> x
y <span style="color: #333333;">=</span> y <span style="color: #333333;">+</span> A[i] <span style="color: #333333;">*</span> m
</pre>
</div>
<br />
The above algorithm runs with for inside another for loop <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>j</mi></math>" id="MathJax-Element-12-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-196" style="display: inline-block; width: 0.598em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.433em;"><span style="clip: rect(1.612em, 1000.42em, 2.801em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-197"><span class="mi" id="MathJax-Span-198" style="font-family: "mathjax_math"; font-style: italic;">j</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.285em; overflow: hidden; vertical-align: -0.341em; width: 0px;"></span></span></nobr></span> multiplications to evaluate <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>a</mi><mi>j</mi></msub><msup><mi>x</mi><mi>j</mi></msup></math>" id="MathJax-Element-13-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-199" style="display: inline-block; width: 2.438em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 1.84em;"><span style="clip: rect(1.226em, 1001.84em, 2.675em, -1000em); left: 0em; position: absolute; top: -2.219em;"><span class="mrow" id="MathJax-Span-200"><span class="msubsup" id="MathJax-Span-201"><span style="display: inline-block; height: 0px; position: relative; width: 0.895em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-202" style="font-family: "mathjax_math"; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mi" id="MathJax-Span-203" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">j</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-204"><span style="display: inline-block; height: 0px; position: relative; width: 0.938em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-205" style="font-family: "mathjax_math"; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.367em;"><span class="mi" id="MathJax-Span-206" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">j</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.219em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.627em; overflow: hidden; vertical-align: -0.46em; width: 0px;"></span></span></nobr></span> and $(n - 1)$ additions in total to evaluate a polynomial. Hence, it does <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>j</mi><mo>=</mo><mn>0</mn></mrow><mi>n</mi></munderover><mi>j</mi><mo>=</mo><mi>n</mi><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo><mrow class="MJX-TeXAtom-ORD"><mo>/</mo></mrow><mn>2</mn></math>" id="MathJax-Element-14-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-207" style="display: inline-block; width: 11.745em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 8.874em;"><span style="clip: rect(1.7em, 1008.82em, 3.243em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-208"><span class="munderover" id="MathJax-Span-209"><span style="display: inline-block; height: 0px; position: relative; width: 2.326em;"><span style="clip: rect(3.092em, 1001em, 4.417em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-210" style="font-family: "mathjax_size1"; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.529em, 1000.5em, 4.174em, -1000em); left: 1.056em; position: absolute; top: -4.481em;"><span class="mi" id="MathJax-Span-211" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">n</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.371em, 1001.27em, 4.311em, -1000em); left: 1.056em; position: absolute; top: -3.719em;"><span class="texatom" id="MathJax-Span-212"><span class="mrow" id="MathJax-Span-213"><span class="mi" id="MathJax-Span-214" style="font-family: "mathjax_math"; font-size: 70.7%; font-style: italic;">j</span><span class="mo" id="MathJax-Span-215" style="font-family: "mathjax_main"; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-216" style="font-family: "mathjax_main"; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mi" id="MathJax-Span-217" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.167em;">j</span><span class="mo" id="MathJax-Span-218" style="font-family: "mathjax_main"; padding-left: 0.278em;">=</span><span class="mi" id="MathJax-Span-219" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.278em;">n</span><span class="mo" id="MathJax-Span-220" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-221" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mo" id="MathJax-Span-222" style="font-family: "mathjax_main"; padding-left: 0.222em;">+</span><span class="mn" id="MathJax-Span-223" style="font-family: "mathjax_main"; padding-left: 0.222em;">1</span><span class="mo" id="MathJax-Span-224" style="font-family: "mathjax_main";">)</span><span class="texatom" id="MathJax-Span-225"><span class="mrow" id="MathJax-Span-226"><span class="mo" id="MathJax-Span-227" style="font-family: "mathjax_main";">/</span></span></span><span class="mn" id="MathJax-Span-228" style="font-family: "mathjax_main";">2</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.752em; overflow: hidden; vertical-align: -0.639em; width: 0px;"></span></span></nobr></span> multiplications and <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mo stretchy="false">(</mo><mi>n</mi><mo>&#x2212;</mo><mn>1</mn><mo stretchy="false">)</mo></math>" id="MathJax-Element-15-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-229" style="display: inline-block; width: 4.007em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 3.03em;"><span style="clip: rect(1.739em, 1002.93em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-230"><span class="mo" id="MathJax-Span-231" style="font-family: "mathjax_main";">(</span><span class="mi" id="MathJax-Span-232" style="font-family: "mathjax_math"; font-style: italic;">n</span><span class="mo" id="MathJax-Span-233" style="font-family: "mathjax_main"; padding-left: 0.222em;">−</span><span class="mn" id="MathJax-Span-234" style="font-family: "mathjax_main"; padding-left: 0.222em;">1</span><span class="mo" id="MathJax-Span-235" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.463em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span> additions. Therefore, the algorithm runs at <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0398;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>2</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-16-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-236" style="display: inline-block; width: 3.358em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.543em;"><span style="clip: rect(1.655em, 1002.45em, 3.064em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-237"><span class="mi" id="MathJax-Span-238" style="font-family: "mathjax_main";">Θ</span><span class="mo" id="MathJax-Span-239" style="font-family: "mathjax_main";">(</span><span class="msubsup" id="MathJax-Span-240"><span style="display: inline-block; height: 0px; position: relative; width: 1.029em;"><span style="clip: rect(3.4em, 1000.58em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-241" style="font-family: "mathjax_math"; font-style: italic;">n</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.6em; position: absolute; top: -4.367em;"><span class="mn" id="MathJax-Span-242" style="font-family: "mathjax_main"; font-size: 70.7%;">2</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-243" style="font-family: "mathjax_main";">)</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.574em; overflow: hidden; vertical-align: -0.401em; width: 0px;"></span></span></nobr></span><br />
time.<br />
This algorithm is obviously worse than Horner’s rule which runs at linear time.<br />
<br />
<b>3. Loop Invariant for the While Loop</b><br />
<br />
<b>Initialization:</b> At the start of the first iteration, we have <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mo>=</mo><mi>n</mi></math>" id="MathJax-Element-17-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-244" style="display: inline-block; width: 2.925em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.219em;"><span style="clip: rect(1.828em, 1002.2em, 2.825em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-245"><span class="mi" id="MathJax-Span-246" style="font-family: "mathjax_math"; font-style: italic;">i</span><span class="mo" id="MathJax-Span-247" style="font-family: "mathjax_main"; padding-left: 0.278em;">=</span><span class="mi" id="MathJax-Span-248" style="font-family: "mathjax_math"; font-style: italic; padding-left: 0.278em;">n</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.03em; overflow: hidden; vertical-align: -0.086em; width: 0px;"></span></span></nobr></span>. So,<br />
<br />
<div style="text-align: center;">
<span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mtr><mtd><mi>y</mi></mtd><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mo>&#x2212;</mo><mn>1</mn></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><mn>0</mn></mtd></mtr></mtable></math>" id="MathJax-Element-18-Frame" role="presentation" style="position: relative; text-align: center;" tabindex="0"><nobr><span class="math" id="MathJax-Span-249" style="display: inline-block; width: 11.962em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 9.037em;"><span style="clip: rect(-3.707em, 1008.87em, 7.644em, -1000em); left: 0em; position: absolute; top: -2.219em;"><span class="mrow" id="MathJax-Span-250"><span class="mtable" id="MathJax-Span-251" style="padding-left: 0.167em; padding-right: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 8.715em;"><span style="clip: rect(5.89em, 1000.5em, 15.615em, -1000em); left: 0em; position: absolute; top: -10.39em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.496em;"><span style="clip: rect(3.4em, 1000.5em, 4.372em, -1000em); position: absolute; right: 0em; top: -7.899em;"><span class="mtd" id="MathJax-Span-252"><span class="mrow" id="MathJax-Span-253"><span class="mi" id="MathJax-Span-254" style="font-family: MathJax_Math; font-style: italic;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -4.508em;"><span class="mtd" id="MathJax-Span-287"><span class="mrow" id="MathJax-Span-288"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -1.264em;"><span class="mtd" id="MathJax-Span-321"><span class="mrow" id="MathJax-Span-322"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: 1.059em;"><span class="mtd" id="MathJax-Span-350"><span class="mrow" id="MathJax-Span-351"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span><span style="display: inline-block; height: 10.39em; width: 0px;"></span></span><span style="clip: rect(5.925em, 1008.22em, 17.098em, -1000em); left: 0.496em; position: absolute; top: -11.851em;"><span style="display: inline-block; height: 0px; position: relative; width: 8.219em;"><span style="clip: rect(2.082em, 1007.86em, 5.498em, -1000em); left: 0em; position: absolute; top: -8.007em;"><span class="mtd" id="MathJax-Span-255"><span class="mrow" id="MathJax-Span-256"><span class="mi" id="MathJax-Span-257"></span><span class="mo" id="MathJax-Span-258" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-259" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.672em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.614em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-260" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.7em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-261"><span class="mrow" id="MathJax-Span-262"><span class="mi" id="MathJax-Span-263" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-264" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-265" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.6em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-266"><span class="mrow" id="MathJax-Span-267"><span class="mi" id="MathJax-Span-268" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-269" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-270" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-271" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-272" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-273" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-274" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-275" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-276" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-277"><span class="mrow" id="MathJax-Span-278"><span class="mi" id="MathJax-Span-279" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-280" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-281" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-282" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-283" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-284"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-285" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-286" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.082em, 1008.22em, 5.498em, -1000em); left: 0em; position: absolute; top: -4.616em;"><span class="mtd" id="MathJax-Span-289"><span class="mrow" id="MathJax-Span-290"><span class="mi" id="MathJax-Span-291"></span><span class="mo" id="MathJax-Span-292" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-293" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.852em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.704em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-294" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.79em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-295"><span class="mrow" id="MathJax-Span-296"><span class="mi" id="MathJax-Span-297" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-298" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-299" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.78em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-300"><span class="mrow" id="MathJax-Span-301"><span class="mi" id="MathJax-Span-302" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-303" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-304" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-305" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-306" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-307" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-308" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-309" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.85em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-310" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-311"><span class="mrow" id="MathJax-Span-312"><span class="mi" id="MathJax-Span-313" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-314" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-315" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-316" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-317" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-318"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-319" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-320" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.121em, 1006.81em, 5.39em, -1000em); left: 0em; position: absolute; top: -1.264em;"><span class="mtd" id="MathJax-Span-323"><span class="mrow" id="MathJax-Span-324"><span class="mi" id="MathJax-Span-325"></span><span class="mo" id="MathJax-Span-326" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-327" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 1.444em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-328" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.086em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-329"><span class="mrow" id="MathJax-Span-330"><span class="mi" id="MathJax-Span-331" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-332" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-333" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.271em, 1000.85em, 4.225em, -1000em); left: 0.27em; position: absolute; top: -5.154em;"><span class="texatom" id="MathJax-Span-334"><span class="mrow" id="MathJax-Span-335"><span class="mo" id="MathJax-Span-336" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mn" id="MathJax-Span-337" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-338" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.85em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-339" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-340"><span class="mrow" id="MathJax-Span-341"><span class="mi" id="MathJax-Span-342" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-343" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-344" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-345" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-346" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-347"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-348" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-349" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.176em, 1001.79em, 4.189em, -1000em); left: 0em; position: absolute; top: 1.059em;"><span class="mtd" id="MathJax-Span-352"><span class="mrow" id="MathJax-Span-353"><span class="mi" id="MathJax-Span-354"></span><span class="mo" id="MathJax-Span-355" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="mn" id="MathJax-Span-356" style="font-family: MathJax_Main; padding-left: 0.278em;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span><span style="display: inline-block; height: 11.851em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.219em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 14.697em; overflow: hidden; vertical-align: -7.019em; width: 0px;"></span></span></nobr></span></div>
As the sum is zero, the loop invariant holds after the first loop.<br />
<strong>Maintenance:</strong> From the loop invariant, for any arbitrary <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>0</mn><mo>&lt;=</mo><mi>i</mi><mo>&lt;</mo><mi>n</mi></math>" id="MathJax-Element-19-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-357" style="display: inline-block; width: 6.388em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 4.816em;"><span style="clip: rect(1.823em, 1004.8em, 2.854em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-358"><span class="mn" id="MathJax-Span-359" style="font-family: MathJax_Main;">0</span><span class="mo" id="MathJax-Span-360" style="font-family: MathJax_Main; padding-left: 0.278em;"><<span style="font-family: MathJax_Main; font-style: normal; font-weight: normal;">=</span></span><span class="mi" id="MathJax-Span-361" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;">i</span><span class="mo" id="MathJax-Span-362" style="font-family: MathJax_Main; padding-left: 0.278em;"><</span><span class="mi" id="MathJax-Span-363" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;">n</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.075em; overflow: hidden; vertical-align: -0.124em; width: 0px;"></span></span></nobr></span><br />
, at the start of the <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math>" id="MathJax-Element-20-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-364" style="display: inline-block; width: 0.436em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.325em;"><span style="clip: rect(1.612em, 1000.28em, 2.608em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-365"><span class="mi" id="MathJax-Span-366" style="font-family: MathJax_Math; font-style: italic;">i</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.03em; overflow: hidden; vertical-align: -0.086em; width: 0px;"></span></span></nobr></span>-th iteration of the while loop of lines 3–5, <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>y</mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></math>" id="MathJax-Element-21-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-367" style="display: inline-block; width: 12.503em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 9.47em;"><span style="clip: rect(1.438em, 1009.47em, 3.156em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-368"><span class="mi" id="MathJax-Span-369" style="font-family: MathJax_Math; font-style: italic;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span><span class="mo" id="MathJax-Span-370" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-371" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 3.803em;"><span style="clip: rect(3.092em, 1001em, 4.417em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-372" style="font-family: MathJax_Size1; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.312em, 1002.75em, 4.343em, -1000em); left: 1.056em; position: absolute; top: -4.526em;"><span class="texatom" id="MathJax-Span-373"><span class="mrow" id="MathJax-Span-374"><span class="mi" id="MathJax-Span-375" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-376" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-377" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-378" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-379" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-380" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-381" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.35em, 4.182em, -1000em); left: 1.056em; position: absolute; top: -3.678em;"><span class="texatom" id="MathJax-Span-382"><span class="mrow" id="MathJax-Span-383"><span class="mi" id="MathJax-Span-384" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-385" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-386" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-387" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-388" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-389"><span class="mrow" id="MathJax-Span-390"><span class="mi" id="MathJax-Span-391" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-392" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-393" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-394" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-395" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-396"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-397" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.367em;"><span class="mi" id="MathJax-Span-398" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.982em; overflow: hidden; vertical-align: -0.523em; width: 0px;"></span></span></nobr></span><br />
Now, after the <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math>" id="MathJax-Element-22-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-399" style="display: inline-block; width: 0.436em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.325em;"><span style="clip: rect(1.612em, 1000.28em, 2.608em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-400"><span class="mi" id="MathJax-Span-401" style="font-family: MathJax_Math; font-style: italic;">i</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.03em; overflow: hidden; vertical-align: -0.086em; width: 0px;"></span></span></nobr></span>-th iteration,<br />
<br />
<div style="text-align: center;">
<span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mtr><mtd><msup><mi>y</mi><mo>&#x2032;</mo></msup></mtd><mtd><mi></mi><mo>=</mo><msub><mi>a</mi><mi>i</mi></msub><mo>+</mo><mi>x</mi><mo>&#x22C5;</mo><mi>y</mi></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><msub><mi>a</mi><mi>i</mi></msub><mo>+</mo><mi>x</mi><mo>&#x22C5;</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><msub><mi>a</mi><mi>i</mi></msub><msup><mi>x</mi><mn>0</mn></msup><mo>+</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mn>1</mn></mrow></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mo>&#x2212;</mo><mn>1</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mn>1</mn></mrow></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><msup><mi>k</mi><mo>&#x2032;</mo></msup><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><msup><mi>k</mi><mo>&#x2032;</mo></msup><mo>+</mo><mi>i</mi></mrow></msub><msup><mi>x</mi><mrow class="MJX-TeXAtom-ORD"><msup><mi>k</mi><mo>&#x2032;</mo></msup></mrow></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><msup><mi>k</mi><mo>&#x2032;</mo></msup><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><msup><mi>i</mi><mo>&#x2032;</mo></msup><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><msup><mi>k</mi><mo>&#x2032;</mo></msup><mo>+</mo><msup><mi>i</mi><mo>&#x2032;</mo></msup><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mrow class="MJX-TeXAtom-ORD"><msup><mi>k</mi><mo>&#x2032;</mo></msup></mrow></msup></mtd></mtr></mtable></math>" id="MathJax-Element-23-Frame" role="presentation" style="position: relative; text-align: center;" tabindex="0"><nobr><span class="math" id="MathJax-Span-402" style="display: inline-block; width: 17.156em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 12.987em;"><span style="clip: rect(-7.299em, 1012.82em, 11.236em, -1000em); left: 0em; position: absolute; top: -2.219em;"><span class="mrow" id="MathJax-Span-403"><span class="mtable" id="MathJax-Span-404" style="padding-left: 0.167em; padding-right: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 12.65em;"><span style="clip: rect(8.394em, 1000.82em, 25.619em, -1000em); left: 0em; position: absolute; top: -17.911em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.817em;"><span style="clip: rect(3.033em, 1000.82em, 4.372em, -1000em); position: absolute; right: 0em; top: -12.55em;"><span class="mtd" id="MathJax-Span-405"><span class="mrow" id="MathJax-Span-406"><span class="msup" id="MathJax-Span-407"><span style="display: inline-block; height: 0px; position: relative; width: 0.817em;"><span style="clip: rect(3.4em, 1000.5em, 4.372em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-408" style="font-family: MathJax_Math; font-style: italic;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.548em; position: absolute; top: -4.417em;"><span class="mo" id="MathJax-Span-409" style="font-family: MathJax_Main; font-size: 70.7%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -10.177em;"><span class="mtd" id="MathJax-Span-421"><span class="mrow" id="MathJax-Span-422"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -6.786em;"><span class="mtd" id="MathJax-Span-461"><span class="mrow" id="MathJax-Span-462"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -3.395em;"><span class="mtd" id="MathJax-Span-506"><span class="mrow" id="MathJax-Span-507"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: 0.039em;"><span class="mtd" id="MathJax-Span-545"><span class="mrow" id="MathJax-Span-546"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: 3.541em;"><span class="mtd" id="MathJax-Span-585"><span class="mrow" id="MathJax-Span-586"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span><span style="display: inline-block; height: 17.911em; width: 0px;"></span></span><span style="clip: rect(9.702em, 1011.83em, 28.011em, -1000em); left: 0.817em; position: absolute; top: -18.994em;"><span style="display: inline-block; height: 0px; position: relative; width: 11.833em;"><span style="clip: rect(3.259em, 1005.19em, 4.372em, -1000em); left: 0em; position: absolute; top: -12.55em;"><span class="mtd" id="MathJax-Span-410"><span class="mrow" id="MathJax-Span-411"><span class="mi" id="MathJax-Span-412"></span><span class="mo" id="MathJax-Span-413" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="msubsup" id="MathJax-Span-414" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.848em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-415" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mi" id="MathJax-Span-416" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-417" style="font-family: MathJax_Main; padding-left: 0.222em;">+</span><span class="mi" id="MathJax-Span-418" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.222em;">x</span><span class="mo" id="MathJax-Span-419" style="font-family: MathJax_Main; padding-left: 0.222em;">⋅</span><span class="mi" id="MathJax-Span-420" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.222em;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(2.082em, 1011.22em, 5.498em, -1000em); left: 0em; position: absolute; top: -10.285em;"><span class="mtd" id="MathJax-Span-423"><span class="mrow" id="MathJax-Span-424"><span class="mi" id="MathJax-Span-425"></span><span class="mo" id="MathJax-Span-426" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="msubsup" id="MathJax-Span-427" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.848em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-428" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mi" id="MathJax-Span-429" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-430" style="font-family: MathJax_Main; padding-left: 0.222em;">+</span><span class="mi" id="MathJax-Span-431" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.222em;">x</span><span class="mo" id="MathJax-Span-432" style="font-family: MathJax_Main; padding-left: 0.222em;">⋅</span><span class="munderover" id="MathJax-Span-433" style="padding-left: 0.222em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.672em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.614em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-434" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.7em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-435"><span class="mrow" id="MathJax-Span-436"><span class="mi" id="MathJax-Span-437" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-438" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-439" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.6em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-440"><span class="mrow" id="MathJax-Span-441"><span class="mi" id="MathJax-Span-442" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-443" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-444" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-445" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-446" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-447" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-448" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-449" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-450" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-451"><span class="mrow" id="MathJax-Span-452"><span class="mi" id="MathJax-Span-453" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-454" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-455" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-456" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-457" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-458"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-459" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-460" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.082em, 1011.83em, 5.498em, -1000em); left: 0em; position: absolute; top: -6.894em;"><span class="mtd" id="MathJax-Span-463"><span class="mrow" id="MathJax-Span-464"><span class="mi" id="MathJax-Span-465"></span><span class="mo" id="MathJax-Span-466" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="msubsup" id="MathJax-Span-467" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.848em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-468" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mi" id="MathJax-Span-469" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-470"><span style="display: inline-block; height: 0px; position: relative; width: 1.001em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-471" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mn" id="MathJax-Span-472" style="font-family: MathJax_Main; font-size: 70.7%;">0</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-473" style="font-family: MathJax_Main; padding-left: 0.222em;">+</span><span class="munderover" id="MathJax-Span-474" style="padding-left: 0.222em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.672em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.614em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-475" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.7em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-476"><span class="mrow" id="MathJax-Span-477"><span class="mi" id="MathJax-Span-478" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-479" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-480" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.6em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-481"><span class="mrow" id="MathJax-Span-482"><span class="mi" id="MathJax-Span-483" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-484" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-485" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-486" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-487" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-488" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-489" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-490" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-491" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-492"><span class="mrow" id="MathJax-Span-493"><span class="mi" id="MathJax-Span-494" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-495" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-496" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-497" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-498" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-499"><span style="display: inline-block; height: 0px; position: relative; width: 1.919em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-500" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="texatom" id="MathJax-Span-501"><span class="mrow" id="MathJax-Span-502"><span class="mi" id="MathJax-Span-503" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-504" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-505" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.082em, 1008.76em, 5.54em, -1000em); left: 0em; position: absolute; top: -3.503em;"><span class="mtd" id="MathJax-Span-508"><span class="mrow" id="MathJax-Span-509"><span class="mi" id="MathJax-Span-510"></span><span class="mo" id="MathJax-Span-511" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-512" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.672em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.614em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-513" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.77em, 4.325em, -1000em); left: 0.425em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-514"><span class="mrow" id="MathJax-Span-515"><span class="mi" id="MathJax-Span-516" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-517" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mo" id="MathJax-Span-518" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mn" id="MathJax-Span-519" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.6em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-520"><span class="mrow" id="MathJax-Span-521"><span class="mi" id="MathJax-Span-522" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-523" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-524" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-525" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-526" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-527" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-528" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-529" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-530" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-531"><span class="mrow" id="MathJax-Span-532"><span class="mi" id="MathJax-Span-533" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-534" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-535" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-536" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-537" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-538"><span style="display: inline-block; height: 0px; position: relative; width: 1.919em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-539" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="texatom" id="MathJax-Span-540"><span class="mrow" id="MathJax-Span-541"><span class="mi" id="MathJax-Span-542" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-543" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-544" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.136em, 1007.34em, 5.639em, -1000em); left: 0em; position: absolute; top: -0.124em;"><span class="mtd" id="MathJax-Span-547"><span class="mrow" id="MathJax-Span-548"><span class="mi" id="MathJax-Span-549"></span><span class="mo" id="MathJax-Span-550" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-551" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.672em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.614em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-552" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.264em, 1001.43em, 4.282em, -1000em); left: 0.605em; position: absolute; top: -2.81em;"><span class="texatom" id="MathJax-Span-553"><span class="mrow" id="MathJax-Span-554"><span class="msup" id="MathJax-Span-555"><span style="display: inline-block; height: 0px; position: relative; width: 0.559em;"><span style="clip: rect(3.351em, 1000.36em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-556" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.368em; position: absolute; top: -4.302em;"><span class="mo" id="MathJax-Span-557" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-558" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-559" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.6em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-560"><span class="mrow" id="MathJax-Span-561"><span class="mi" id="MathJax-Span-562" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-563" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-564" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-565" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-566" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-567" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-568" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-569" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 1.957em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-570" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.771em;"><span class="texatom" id="MathJax-Span-571"><span class="mrow" id="MathJax-Span-572"><span class="msup" id="MathJax-Span-573"><span style="display: inline-block; height: 0px; position: relative; width: 0.559em;"><span style="clip: rect(3.351em, 1000.36em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-574" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.368em; position: absolute; top: -4.302em;"><span class="mo" id="MathJax-Span-575" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-576" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-577" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-578"><span style="display: inline-block; height: 0px; position: relative; width: 1.206em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-579" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="texatom" id="MathJax-Span-580"><span class="mrow" id="MathJax-Span-581"><span class="msup" id="MathJax-Span-582"><span style="display: inline-block; height: 0px; position: relative; width: 0.559em;"><span style="clip: rect(3.351em, 1000.36em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-583" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.368em; position: absolute; top: -4.302em;"><span class="mo" id="MathJax-Span-584" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.167em; width: 0px;"></span></span><span style="clip: rect(2.166em, 1008.62em, 5.693em, -1000em); left: 0em; position: absolute; top: 3.324em;"><span class="mtd" id="MathJax-Span-587"><span class="mrow" id="MathJax-Span-588"><span class="mi" id="MathJax-Span-589"></span><span class="mo" id="MathJax-Span-590" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-591" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.863em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.709em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-592" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.264em, 1001.43em, 4.282em, -1000em); left: 0.7em; position: absolute; top: -2.81em;"><span class="texatom" id="MathJax-Span-593"><span class="mrow" id="MathJax-Span-594"><span class="msup" id="MathJax-Span-595"><span style="display: inline-block; height: 0px; position: relative; width: 0.559em;"><span style="clip: rect(3.351em, 1000.36em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-596" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.368em; position: absolute; top: -4.302em;"><span class="mo" id="MathJax-Span-597" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-598" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-599" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.188em, 1002.8em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-600"><span class="mrow" id="MathJax-Span-601"><span class="mi" id="MathJax-Span-602" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-603" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-604" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="msup" id="MathJax-Span-605"><span style="display: inline-block; height: 0px; position: relative; width: 0.434em;"><span style="clip: rect(3.375em, 1000.21em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-606" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.244em; position: absolute; top: -4.279em;"><span class="mo" id="MathJax-Span-607" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-608" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-609" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-610" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-611" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 3.051em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-612" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.771em;"><span class="texatom" id="MathJax-Span-613"><span class="mrow" id="MathJax-Span-614"><span class="msup" id="MathJax-Span-615"><span style="display: inline-block; height: 0px; position: relative; width: 0.559em;"><span style="clip: rect(3.351em, 1000.36em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-616" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.368em; position: absolute; top: -4.302em;"><span class="mo" id="MathJax-Span-617" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-618" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="msup" id="MathJax-Span-619"><span style="display: inline-block; height: 0px; position: relative; width: 0.434em;"><span style="clip: rect(3.375em, 1000.21em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-620" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.244em; position: absolute; top: -4.279em;"><span class="mo" id="MathJax-Span-621" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-622" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-623" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-624"><span style="display: inline-block; height: 0px; position: relative; width: 1.206em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-625" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="texatom" id="MathJax-Span-626"><span class="mrow" id="MathJax-Span-627"><span class="msup" id="MathJax-Span-628"><span style="display: inline-block; height: 0px; position: relative; width: 0.559em;"><span style="clip: rect(3.351em, 1000.36em, 4.174em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-629" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.368em; position: absolute; top: -4.302em;"><span class="mo" id="MathJax-Span-630" style="font-family: MathJax_Main; font-size: 50%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.221em; width: 0px;"></span></span></span><span style="display: inline-block; height: 18.994em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.219em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 24.18em; overflow: hidden; vertical-align: -11.76em; width: 0px;"></span></span></nobr></span>
</div>
So, the loop invariant also holds after the loop.<br />
We make two assumption:<br />
<ol style="text-align: left;">
<li> <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>k</mi><mo>&#x2032;</mo></msup><mo>=</mo><mi>k</mi><mo>+</mo><mn>1</mn></math>" id="MathJax-Element-24-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-631" style="display: inline-block; width: 5.739em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 4.329em;"><span style="clip: rect(1.73em, 1004.26em, 2.896em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-632"><span class="msup" id="MathJax-Span-633"><span style="display: inline-block; height: 0px; position: relative; width: 0.79em;"><span style="clip: rect(3.148em, 1000.5em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-634" style="font-family: MathJax_Math; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.521em; position: absolute; top: -4.367em;"><span class="mo" id="MathJax-Span-635" style="font-family: MathJax_Main; font-size: 70.7%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-636" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="mi" id="MathJax-Span-637" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;">k</span><span class="mo" id="MathJax-Span-638" style="font-family: MathJax_Main; padding-left: 0.222em;">+</span><span class="mn" id="MathJax-Span-639" style="font-family: MathJax_Main; padding-left: 0.222em;">1</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.253em; overflow: hidden; vertical-align: -0.18em; width: 0px;"></span></span></nobr></span> : This is valid as <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>k</mi></math>" id="MathJax-Element-25-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-640" style="display: inline-block; width: 0.76em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.541em;"><span style="clip: rect(1.579em, 1000.52em, 2.608em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-641"><span class="mi" id="MathJax-Span-642" style="font-family: MathJax_Math; font-style: italic;">k</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.073em; overflow: hidden; vertical-align: -0.086em; width: 0px;"></span></span></nobr></span> is nothing but the summation parameter.</li>
<li><span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><msup><mi>i</mi><mo>&#x2032;</mo></msup><mo>=</mo><mi>i</mi><mo>&#x2212;</mo><mn>1</mn></math>" id="MathJax-Element-26-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-643" style="display: inline-block; width: 5.252em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 3.95em;"><span style="clip: rect(1.73em, 1003.88em, 2.896em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-644"><span class="msup" id="MathJax-Span-645"><span style="display: inline-block; height: 0px; position: relative; width: 0.614em;"><span style="clip: rect(3.181em, 1000.3em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-646" style="font-family: MathJax_Math; font-style: italic;">i</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.345em; position: absolute; top: -4.367em;"><span class="mo" id="MathJax-Span-647" style="font-family: MathJax_Main; font-size: 70.7%;">′</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="mo" id="MathJax-Span-648" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="mi" id="MathJax-Span-649" style="font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;">i</span><span class="mo" id="MathJax-Span-650" style="font-family: MathJax_Main; padding-left: 0.222em;">−</span><span class="mn" id="MathJax-Span-651" style="font-family: MathJax_Main; padding-left: 0.222em;">1</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.253em; overflow: hidden; vertical-align: -0.18em; width: 0px;"></span></span></nobr></span> : This holds as this is precisely the operation done in line 5. </li>
</ol>
<strong>Termination:</strong> When the loop terminates, we have <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi><mo>=</mo><mo>&#x2212;</mo><mn>1</mn></math>" id="MathJax-Element-27-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-652" style="display: inline-block; width: 3.791em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 2.868em;"><span style="clip: rect(1.823em, 1002.79em, 2.896em, -1000em); left: 0em; position: absolute; top: -2.652em;"><span class="mrow" id="MathJax-Span-653"><span class="mi" id="MathJax-Span-654" style="font-family: MathJax_Math; font-style: italic;">i</span><span class="mo" id="MathJax-Span-655" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="mo" id="MathJax-Span-656" style="font-family: MathJax_Main; padding-left: 0.278em;">−</span><span class="mn" id="MathJax-Span-657" style="font-family: MathJax_Main;">1</span></span><span style="display: inline-block; height: 2.652em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.13em; overflow: hidden; vertical-align: -0.18em; width: 0px;"></span></span></nobr></span>. So,<br />
<br />
<div style="text-align: center;">
<span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mtable columnalign="right left right left right left right left right left right left" rowspacing="3pt" columnspacing="0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em" displaystyle="true"><mtr><mtd><mi>y</mi></mtd><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>+</mo><mi>i</mi><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow class="MJX-TeXAtom-ORD"><mi>n</mi><mo>&#x2212;</mo><mo stretchy="false">(</mo><mo>&#x2212;</mo><mn>1</mn><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></munderover><msub><mi>a</mi><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>&#x2212;</mo><mn>1</mn><mo>+</mo><mn>1</mn></mrow></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr><mtr><mtd /><mtd><mi></mi><mo>=</mo><munderover><mo>&#x2211;</mo><mrow class="MJX-TeXAtom-ORD"><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mi>n</mi></munderover><msub><mi>a</mi><mi>k</mi></msub><msup><mi>x</mi><mi>k</mi></msup></mtd></mtr></mtable></math>" id="MathJax-Element-28-Frame" role="presentation" style="position: relative; text-align: center;" tabindex="0"><nobr><span class="math" id="MathJax-Span-658" style="display: inline-block; width: 12.503em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 9.47em;"><span style="clip: rect(-2.978em, 1009.3em, 6.915em, -1000em); left: 0em; position: absolute; top: -2.219em;"><span class="mrow" id="MathJax-Span-659"><span class="mtable" id="MathJax-Span-660" style="padding-left: 0.167em; padding-right: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 9.124em;"><span style="clip: rect(4.13em, 1000.5em, 11.374em, -1000em); left: 0em; position: absolute; top: -7.9em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.496em;"><span style="clip: rect(3.4em, 1000.5em, 4.372em, -1000em); position: absolute; right: 0em; top: -7.17em;"><span class="mtd" id="MathJax-Span-661"><span class="mrow" id="MathJax-Span-662"><span class="mi" id="MathJax-Span-663" style="font-family: MathJax_Math; font-style: italic;">y<span style="display: inline-block; height: 1px; overflow: hidden; width: 0.006em;"></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -3.779em;"><span class="mtd" id="MathJax-Span-696"><span class="mrow" id="MathJax-Span-697"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.842em, 1000em, 4.167em, -1000em); position: absolute; right: 0em; top: -0.693em;"><span class="mtd" id="MathJax-Span-731"><span class="mrow" id="MathJax-Span-732"></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span><span style="display: inline-block; height: 7.9em; width: 0px;"></span></span><span style="clip: rect(5.356em, 1008.63em, 15.248em, -1000em); left: 0.496em; position: absolute; top: -10.552em;"><span style="display: inline-block; height: 0px; position: relative; width: 8.628em;"><span style="clip: rect(2.082em, 1007.86em, 5.498em, -1000em); left: 0em; position: absolute; top: -7.278em;"><span class="mtd" id="MathJax-Span-664"><span class="mrow" id="MathJax-Span-665"><span class="mi" id="MathJax-Span-666"></span><span class="mo" id="MathJax-Span-667" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-668" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.672em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.614em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-669" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.7em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-670"><span class="mrow" id="MathJax-Span-671"><span class="mi" id="MathJax-Span-672" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-673" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-674" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1002.6em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-675"><span class="mrow" id="MathJax-Span-676"><span class="mi" id="MathJax-Span-677" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-678" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-679" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mi" id="MathJax-Span-680" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-681" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-682" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-683" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-684" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.67em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-685" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-686"><span class="mrow" id="MathJax-Span-687"><span class="mi" id="MathJax-Span-688" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-689" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mi" id="MathJax-Span-690" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">i</span><span class="mo" id="MathJax-Span-691" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-692" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-693"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-694" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-695" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.082em, 1008.63em, 5.498em, -1000em); left: 0em; position: absolute; top: -3.887em;"><span class="mtd" id="MathJax-Span-698"><span class="mrow" id="MathJax-Span-699"><span class="mi" id="MathJax-Span-700"></span><span class="mo" id="MathJax-Span-701" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-702" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 3.332em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0.944em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-703" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 1.03em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-704"><span class="mrow" id="MathJax-Span-705"><span class="mi" id="MathJax-Span-706" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-707" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-708" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.212em, 1003.27em, 4.343em, -1000em); left: 0em; position: absolute; top: -5.242em;"><span class="texatom" id="MathJax-Span-709"><span class="mrow" id="MathJax-Span-710"><span class="mi" id="MathJax-Span-711" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span class="mo" id="MathJax-Span-712" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mo" id="MathJax-Span-713" style="font-family: MathJax_Main; font-size: 70.7%;">(</span><span class="mo" id="MathJax-Span-714" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mn" id="MathJax-Span-715" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-716" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-717" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-718" style="font-family: MathJax_Main; font-size: 70.7%;">)</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-719" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 2.78em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-720" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="texatom" id="MathJax-Span-721"><span class="mrow" id="MathJax-Span-722"><span class="mi" id="MathJax-Span-723" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-724" style="font-family: MathJax_Main; font-size: 70.7%;">−</span><span class="mn" id="MathJax-Span-725" style="font-family: MathJax_Main; font-size: 70.7%;">1</span><span class="mo" id="MathJax-Span-726" style="font-family: MathJax_Main; font-size: 70.7%;">+</span><span class="mn" id="MathJax-Span-727" style="font-family: MathJax_Main; font-size: 70.7%;">1</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-728"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-729" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-730" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.113em; width: 0px;"></span></span><span style="clip: rect(2.279em, 1004.93em, 5.39em, -1000em); left: 0em; position: absolute; top: -0.693em;"><span class="mtd" id="MathJax-Span-733"><span class="mrow" id="MathJax-Span-734"><span class="mi" id="MathJax-Span-735"></span><span class="mo" id="MathJax-Span-736" style="font-family: MathJax_Main; padding-left: 0.278em;">=</span><span class="munderover" id="MathJax-Span-737" style="padding-left: 0.278em;"><span style="display: inline-block; height: 0px; position: relative; width: 1.444em;"><span style="clip: rect(2.892em, 1001.39em, 4.617em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mo" id="MathJax-Span-738" style="font-family: MathJax_Size2; vertical-align: 0em;">∑</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.351em, 1001.24em, 4.282em, -1000em); left: 0.086em; position: absolute; top: -2.897em;"><span class="texatom" id="MathJax-Span-739"><span class="mrow" id="MathJax-Span-740"><span class="mi" id="MathJax-Span-741" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span class="mo" id="MathJax-Span-742" style="font-family: MathJax_Main; font-size: 70.7%;">=</span><span class="mn" id="MathJax-Span-743" style="font-family: MathJax_Main; font-size: 70.7%;">0</span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="clip: rect(3.429em, 1000.41em, 4.174em, -1000em); left: 0.51em; position: absolute; top: -5.154em;"><span class="mi" id="MathJax-Span-744" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">n</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-745" style="padding-left: 0.167em;"><span style="display: inline-block; height: 0px; position: relative; width: 0.972em;"><span style="clip: rect(3.401em, 1000.51em, 4.177em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-746" style="font-family: MathJax_Math; font-style: italic;">a</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.529em; position: absolute; top: -3.854em;"><span class="mi" id="MathJax-Span-747" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span><span class="msubsup" id="MathJax-Span-748"><span style="display: inline-block; height: 0px; position: relative; width: 1.015em;"><span style="clip: rect(3.4em, 1000.52em, 4.178em, -1000em); left: 0em; position: absolute; top: -4.004em;"><span class="mi" id="MathJax-Span-749" style="font-family: MathJax_Math; font-style: italic;">x</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span><span style="left: 0.572em; position: absolute; top: -4.417em;"><span class="mi" id="MathJax-Span-750" style="font-family: MathJax_Math; font-size: 70.7%; font-style: italic;">k</span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span></span></span></span><span style="display: inline-block; height: 4.004em; width: 0px;"></span></span></span><span style="display: inline-block; height: 10.552em; width: 0px;"></span></span></span></span></span><span style="display: inline-block; height: 2.219em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 12.772em; overflow: hidden; vertical-align: -6.056em; width: 0px;"></span></span></nobr></span> </div>
This is precisely what we wanted to calculate.<br />
<br />
<b>4. Correctness Argument</b><br />
When Horner’s rule terminates it successfully evaluates the polynomial as it intended to. This means the algorithm is correct.</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-15583355378505521162017-05-25T03:19:00.002-07:002017-05-25T03:19:21.345-07:00Chapter 2 1-2 Problems, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<b>2-1 Insertion sort on small arrays in merge sort </b><br />
Although merge sort runs in Θ(nlgn) worst-case time and insertion sort runs in Θ(n2) worst-case time, the constant factors in insertion sort make it faster for small n. Thus, it makes sense to use insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of length k are sorted using insertion sort and then merged using the standard merging mechanism, where k is a value to be determined.<br />
<ol style="text-align: left;">
<li>Show that the n/k sublists, each of length k, can be sorted by insertion sort in Θ(nk) worst-case time.</li>
<li>Show that the sublists can be merged in Θ(nlg(n/k)) worst-case time.</li>
<li>Given that the modified algorithm runs in Θ(nk+nlg(n/k)) worst-case time, what is the largest asymptotic (Θ-notation) value of k as a function of n for which the modified algorithm has the same asymptotic running time as standard merge sort , in terms of Θ-notation?</li>
<li>How should k be chosen in practice?</li>
</ol>
Solution:<br />
<b>1. Sorting Sublists</b><br />
For input of size k, insertion sort runs on Θ(k<sup>2</sup>) worst-case time, i.e. running time of the form (ak<sup>2</sup>+bk+c). So, worst-case time required to sort n/k sublists, each of length k, with insertion sort:<br />
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
$$T(k) = \frac n k (ak^2 +bk +c) = ank + bn + \frac {cn} k$$</div>
<br />
Now, k is an integer significantly smaller than n. So, for sufficiently large values of n, we can ignore the last two term of T(k). So, T(k)=Θ(nk).<br />
<b>2. Merging Sublists</b><br />
We have n elements divided into n/k sorted sublists each of length k. To merge these n/k sorted sublists to get a single sorted list of length n, we have to take 2 sublists at a time and continue to merge them. This will result in log(n/k) steps. And in every step, we are essentially going to compare n elements. So the whole process will run at Θ(nlg(n/k)).<br />
<b>3. Largest Value of <span class="MathJax" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>k</mi></math>" id="MathJax-Element-35-Frame" role="presentation" style="position: relative;" tabindex="0"><nobr><span class="math" id="MathJax-Span-243" style="display: inline-block; width: 0.76em;"><span style="display: inline-block; font-size: 132%; height: 0px; position: relative; width: 0.541em;"><span style="clip: rect(1.579em, 1000.52em, 2.608em, -1000em); left: 0em; position: absolute; top: -2.435em;"><span class="mrow" id="MathJax-Span-244"><span class="mi" id="MathJax-Span-245" style="font-family: "mathjax_math"; font-style: italic;">k</span></span><span style="display: inline-block; height: 2.435em; width: 0px;"></span></span></span><span style="border-left: 0px solid; display: inline-block; height: 1.073em; overflow: hidden; vertical-align: -0.086em; width: 0px;"></span></span></nobr></span></b><br />
For the modified algorithm to have the same asymptotic running time as standard merge sort, Θ(nk+nlg(n/k))=Θ(nk+nlgn−nlgk) must be same as Θ(nlgn)<br />
<br />
To satisfy this condition, k cannot grow faster than lgn asymptotically (if k grows faster than lgn, because of the nk term, the algorithm will run at worse asymptotic time than Θ(nlgn). But just this argument is not enough as we have to check for k=Θ(lgn), the requirement holds or not.<br />
<br />
If we assume, k=Θ(lgn),<br />
<div style="text-align: center;">
Θ(nk+nlg(n/k))=Θ(nk+nlgn−nlgk)</div>
<div style="text-align: center;">
=Θ(nlgn+nlgn−nlg(lgn))</div>
<div style="text-align: center;">
=Θ(2nlgn−nlg(lgn))</div>
<div style="text-align: center;">
=Θ(nlgn) </div>
<div style="text-align: left;">
<b>4. Practical Value of k</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
In practice, k should be the largest list length on which insertion sort is faster than merge sort.</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<b>2-2 Correctness of bubble-sort</b></div>
<div style="text-align: left;">
Bubble-sort is a popular, but inefficient, sorting algorithm. It works by repeatedly swapping adjacent elements that are out of order. </div>
<div style="text-align: left;">
<br /></div>
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">BUBBLESORT(A)
<span style="color: #008800; font-weight: bold;">for</span> i to A<span style="color: #333333;">.</span>length <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">for</span> j <span style="color: #333333;">=</span> A<span style="color: #333333;">.</span>length downto i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">if</span> A[j] <span style="color: #333333;"><</span> A[j <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>]
exchange A[j] <span style="color: #008800; font-weight: bold;">with</span> A[j <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>]
</pre>
</div>
<br />
<ol style="text-align: left;">
<li>Let A′ denote the output of BUBBLESORT(A). To prove that BUBBLESORT is correct, we need to prove that it terminates and that A′[1]≤A′[2]≤⋯≤A′[n](2.3) where n=length[A]. What else must be proved to show that BUBBLESORT actually sorts? </li>
<li>State precisely a loop invariant for the for loop in lines 2–4, and prove that this loop invariant holds. Your proof should use the structure of the loop invariant proof presented in this chapter.</li>
<li>Using the termination condition of the loop invariant proved in part (2), state a loop invariant for the for loop in lines 1–4 that will allow you to prove inequality (2.3). Your proof should use the structure of the loop invariant proof presented in this chapter. </li>
<li>What is the worst-case running time of bubblesort? How does it compare to the running time of insertion sort?</li>
</ol>
Solution:<br />
1. Required Proof of Correctnesses<br />
We also need to prove that A′ consists of the elements originally in A but in sorted order.<br />
2. Loop Invariant for Inner Loop<br />
The loop invariant for the for loop in lines 2–4 can be stated as follows:<br />
At the start of each iteration of the for loop, the subarray A[j..n] consists of the elements originally in A[j..n] before entering the loop but possibly in a different order and the first element is the smallest among them.<br />
And here is how the three necessary properties hold for the loop invariant:<br />
<br />
Initialization: Initially the subarray contains only the last element A[n] and this is the smallest element of the subarray.<br />
<br />
Maintenance: In every step we compare A[j] with A[j−1] and make A[j−1] the smallest among them. So, after the iteration, , the length of the subarray increases by one and the first element is the smallest of the subarray. <br />
<br />
Termination: The loop terminates when j=i+1. At that point also the length of the subarray increases by one and the first element is the smallest of the subarray as we swap A[i+1] with A[i].<br />
<br />
3. Loop Invariant for the Outer Loop<br />
<br />
The loop invariant for the for loop in lines 1–4 can be stated as follows:<br />
<br />
At the start of each iteration of the for loop, the subarray A[1..i−1] consists of the elements that are smaller than the elements in the subarray A[i..n] in sorted order.<br />
<br />
And here is how the three necessary properties hold for the loop invariant:<br />
<br />
Initialization: Initially the subarray A[1..i−1] is empty and trivially this is the smallest element of the subarray.<br />
<br />
Maintenance: From part (2), after the execution of the inner loop, A[i] will be the smallest element of the subarray A[i..n]. And in the beginning of the outer loop, A[1..i−1] consists of elements that are smaller than the elements of A[i..n], in sorted order. So, after the execution of the outer loop, subarray A[1..i] will consists of elements that are smaller than the elements of A[i+1..n] , in sorted order.<br />
<br />
Termination: The loop terminates when i=A.length. At that point the array A[1..n] will consists of all elements in sorted order.<br />
<br />
4. Running Time of Bubblesort<br />
<ul style="text-align: left;">
<li>At worst-case, bubblesort will iterate over the whole array for each element, i.e. for each element bubble sort will perform n comparisons and swaps. Therefore, worst-case running time of bubblesort is Θ(n<sup>2</sup>).</li>
<li>Although insertion also runs at Θ(n<sup>2</sup>) worst-case time, the number of assignments (swaps) performed in bubblesort is way more than that of insertion sort. So, the constant factors in the running time will be much larger for bubblesort compared to that of insertion sort. This means, for the same input size, insertion sort will run faster than bubblesort. </li>
</ul>
<ul style="text-align: left;">
</ul>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-49026883374188759402017-04-04T00:28:00.002-07:002017-04-04T00:28:53.895-07:00Chapter 2 Exercise 2.3, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
2.3-1 Using Figure 2.4 as a model, illustrate the operation of merge sort on the array A=<3,41,52,26,38,57,9,49><br />
<br />
Solution:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3_aCd0Da5lLMusnOvOCoRNtf-Xu82CvQpBq_hMHrYBzMq3bKzcYbXhnyZ2gdKjRoBVKw-x-h6DzqOX5Z4w1B4JryxlBaRDR3JBU5cOWrSJB4CCWl5qvMZL2p2NJqUY7dFdyqWMvSU37k/s1600/sort+merge.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3_aCd0Da5lLMusnOvOCoRNtf-Xu82CvQpBq_hMHrYBzMq3bKzcYbXhnyZ2gdKjRoBVKw-x-h6DzqOX5Z4w1B4JryxlBaRDR3JBU5cOWrSJB4CCWl5qvMZL2p2NJqUY7dFdyqWMvSU37k/s320/sort+merge.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
2.3-2 Rewrite the MERGE procedure so that it does not use sentinels, instead stopping once either array L or R has had all its elements copied back to A and then copying the remainder of the other array back into A.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Solution:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
</div>
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">MERGE(A, p, q, r)
n1 <span style="color: #333333;">=</span> q <span style="color: #333333;">-</span> p <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
n2 <span style="color: #333333;">=</span> r <span style="color: #333333;">-</span> q
create arrays L[<span style="color: #6600ee; font-weight: bold;">1.</span><span style="color: #333333;">.</span>n1] <span style="color: black; font-weight: bold;">and</span> R[<span style="color: #6600ee; font-weight: bold;">1.</span><span style="color: #333333;">.</span>n2]
<span style="color: #008800; font-weight: bold;">for</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to n1
L[i] <span style="color: #333333;">=</span> A[p <span style="color: #333333;">+</span> i <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>]
<span style="color: #008800; font-weight: bold;">for</span> j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to n2
R[j] <span style="color: #333333;">=</span> A[q <span style="color: #333333;">+</span> j]
i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span>
j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">for</span> k <span style="color: #333333;">=</span> p to r
<span style="color: #008800; font-weight: bold;">if</span> i <span style="color: #333333;">></span> n1
A[k] <span style="color: #333333;">=</span> R[j]
j <span style="color: #333333;">=</span> j <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> j <span style="color: #333333;">></span> n2
A[k] <span style="color: #333333;">=</span> L[i]
i <span style="color: #333333;">=</span> i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> L[i] <span style="background-color: #ffaaaa; color: red;">≤</span> R[j]
A[k] <span style="color: #333333;">=</span> L[i]
i <span style="color: #333333;">=</span> i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">else</span>
A[k] <span style="color: #333333;">=</span> R[j]
j <span style="color: #333333;">=</span> j <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
</pre>
</div>
</div>
<br />
2.3-3 Use mathematical induction to show that when n is an exact power of 2, the solution of the recurrence<br />
<div style="text-align: center;">
$$T(n) = \begin{cases}
2 & \text{if } n = 2, \\
2T(n/2) + n & \text{if } n = 2^k, \text{for } k > 1.
\end{cases}$$<br />
<div style="text-align: left;">
is $$T(n) = n\lg{n}$$<br />
<br />
Solution:<br />
<br />
First, let's establish a function on which we're going to perform induction:<br />
<div style="text-align: center;">
$$F(k) = T(2^k)$$</div>
<div style="text-align: left;">
We want to prove that:</div>
<div style="text-align: center;">
$$F(k) = 2^k \lg{2^k}$$</div>
<div style="text-align: left;">
<b>Base.</b> It is simple enough:</div>
<div style="text-align: center;">
$$F(1) = T(2) = 2 = 2\lg2 = 2^1\lg{2^1}$$</div>
<div style="text-align: left;">
<b>Step.</b> We assume that:</div>
<div style="text-align: center;">
$$F(k) = 2^k \lg{2^k}$$</div>
<div style="text-align: left;">
We prove it for k+1:<br />
<div style="text-align: center;">
$$\begin{align}
F(k + 1) & = T(2^{k+1})= 2T(\frac{2^{k+1}}{2}) + 2^{k+1} = \\
& = 2T(2^k) + 2^{k+1} = 2 \cdot 2^k \lg{2^k} + 2^{k+1} = \\
& = 2^{k+1}(\lg{2^k} + 1) = 2^{k+1}(\lg{2^k} + \lg2) = \\
& = 2^{k+1}\lg{2^{k+1}}
\end{align}$$<br />
<div style="text-align: left;">
<br />
2.3-4 We can express insertion sort as a recursive procedure as follows. In order to sort. In order to sort A[1..n], we recursively sort A[1..n−1] and then insert A[n] into the sorted array A[1..n−1]. Write a recurrence for the running time of this recursive version of insertion sort.<br />
<br />
Solution:<br />
<br />
There are two steps in this recursive sorting algorithm:<br />
<ol style="text-align: left;">
<li> Sort the sub-array A[1..n−1]</li>
<li>Insert A[n] into the sorted sub-array from step 1 in proper position </li>
</ol>
For n=1, step 1 doesn’t take any time as the sub-array is an empty array and step 2 takes constant time, i.e. the algorithm runs in Θ(1) time.<br />
For n>1, step 1 again calls for the recursion for n−1 and step 2 runs in Θ(n) time.<br />
<br />
So, we can write the recurrence as: </div>
$$% <![CDATA[
T(n) = \begin {cases}
\Theta(1) & \text { if } n = 1, \\
T(n - 1) + \Theta(n) & \text { if } n > 1
\end {cases} %]]>$$<br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Solution to the Recurrence: Let us assume that for n=1, T(n)=c<sub>1</sub>, where c<sub>1</sub> is some constant. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
And on average for n>1, inserting an element in its proper position in a sorted array requires shifting half of the elements, i.e. c<sub>2</sub>n/2+c<sub>3</sub> time (c<sub>2</sub>n/2 for shifting the elements and c<sub>3</sub><br />
<br />
for inserting the element).<br />
<br />
So, we can rewrite the recurrence as:<br />
$$% <![CDATA[
T(n) = \begin {cases}
c_1 & \text { if } n = 1, \\
T(n - 1) + c_2(n - 1)/2 + c_3 & \text { if } n > 1
\end {cases} %]]>$$<br />
So for any general n>1,</div>
$$% <![CDATA[
\begin {align}
T(n) & = T(n - 1) + c_2(n - 1)/2 + c_3 \\
& = T(n - 2) + c_2(n - 2)/2 + c_3 + \{c_2(n - 1)/2 + c_3\} \\
& = T(1) + \cdot \cdot \cdot + \{c_2(n - 2)/2 + c_3\} + \{c_2(n - 1)/2 + c_3\} \\
& = c_1 + \frac {c_2} 2 \{1 + 2 + \cdot \cdot \cdot + (n - 1)\} + c_3(n - 1) \\
& = c_1 + \frac {c_2} 2 \cdot \frac {n(n - 1)} 2 + c_3(n - 1) \\
& = \Theta(n^2)
\end {align} %]]>$$<br />
<br />
<div style="text-align: left;">
2.3-5 Referring back to the searching problem (see Exercise 2.1-3), observe that if the sequence A is sorted, we can check the midpoint of the sequence against and eliminate half of the sequence from further consideration. The binary search algorithm repeats this procedure, halving the size of the remaining portion of the sequence each time. Write pseudocode, either iterative or recursive, for binary search. Argue that the worst-case running time of binary search is Θ(lgn).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Solution:</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Pseudo-code:</div>
<div style="text-align: left;">
<br /></div>
<div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;">
<pre style="line-height: 125%; margin: 0px;">ITERATIVE<span style="color: #333333;">-</span>BINARY_SEARCH(A, v)
low <span style="color: #333333;">=</span> A[<span style="color: #0000dd; font-weight: bold;">1</span>]
high <span style="color: #333333;">=</span> A[A<span style="color: #333333;">.</span>length]
<span style="color: #008800; font-weight: bold;">while</span> low <span style="color: #333333;">&</span>le; high
mid <span style="color: #333333;">=</span> (low <span style="color: #333333;">+</span> high) <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">2</span>
<span style="color: #008800; font-weight: bold;">if</span> v <span style="color: #333333;">==</span> A[mid]
<span style="color: #008800; font-weight: bold;">return</span> mid
elseif v <span style="color: #333333;">></span> A[mid]
low <span style="color: #333333;">=</span> mid <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">else</span>
high <span style="color: #333333;">=</span> mid <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #008800; font-weight: bold;">return</span> NIL
</pre>
</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
</div>
<div style="background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: medium solid gray; overflow: auto; padding: 0.2em 0.6em; text-align: left; width: auto;">
<pre style="line-height: 125%; margin: 0px;">RECURSIVE<span style="color: #333333;">-</span>BINARY<span style="color: #333333;">-</span>SEARCH(A, v, low, high)
<span style="color: #008800; font-weight: bold;">if</span> low <span style="color: #333333;">></span> high
<span style="color: #008800; font-weight: bold;">return</span> NIL
mid <span style="color: #333333;">=</span> (low <span style="color: #333333;">+</span> high) <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">2</span>
<span style="color: #008800; font-weight: bold;">if</span> v <span style="color: #333333;">==</span> A[mid]
<span style="color: #008800; font-weight: bold;">return</span> mid
elseif v <span style="color: #333333;">></span> A[mid]
RECURSIVE<span style="color: #333333;">-</span>BINARY<span style="color: #333333;">-</span>SEARCH(A, v, mid <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>, high)
<span style="color: #008800; font-weight: bold;">else</span>
RECURSIVE<span style="color: #333333;">-</span>BINARY<span style="color: #333333;">-</span>SEARCH(A, v, low, mid <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>)
</pre>
</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Intuitively, in worst case, i.e. when v is not at all present in A, we need to binary search over the whole array to return NIL. So in worst-case, we need to repeatedly divide the array by 2. So the running time is nothing but how many times the input size can be divided by 2, i.e. lgn.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
And using recurrence formula, we can say running time T(n)=T((n−1)/2)+Θ(1)=Θ(lgn).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
2.3-6 Observe that the while loop of lines 5–7 of the INSERTION-SORT procedure in Section 2.1 uses a linear search to scan (backward) through the sorted subarray A[1..j−1]. Can we use a binary search (see Exercise 2.3-5) instead to improve the overall worst-case running time of insertion sort to Θ(nlgn)?</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Solution:</div>
<div style="text-align: left;">
Insertion sort has a loop like this</div>
<div style="text-align: left;">
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">while</span> i <span style="color: #333333;">></span> <span style="color: #0000dd; font-weight: bold;">0</span> <span style="color: black; font-weight: bold;">and</span> A[i] <span style="color: #333333;">></span> key
A[i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span>] <span style="color: #333333;">=</span> A[i]
i <span style="color: #333333;">=</span> i <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>
</pre>
</div>
<br /></div>
<div style="text-align: left;">
This loop serves two purposes:<br />
<ol style="text-align: left;">
<li>A linear search to scan (backward) through the sorted sub-array to find the proper position for key.</li>
<li>Shift the elements greater than key towards the end to insert key in the proper position.</li>
</ol>
Although we can reduce the number of comparisons by using binary search to accomplish purpose 1, we still need to shift all the elements greater than key towards the end of the array to insert key. And this shifting of elements runs at Θ(n) time, even in average case (as we need to shift half of the elements). So, the overall worst-case running time of insertion sort will still be Θ(n<sup>2</sup>).<br />
<br /></div>
<div style="text-align: left;">
2.3-7 Describe a Θ(nlgn)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x.<br />
<br />
Solution:<br />
<br />
First we sort S. Afterwards, we iterate it and for each element i we perform a binary search to see if there is an element equal to x−i. If one is found, the algorithm returns true. Otherwise, it returns false.<br />
<br />
We iterate n elements and perform binary search for each on in an n-sized array, which leads to Θ(nlgn)-time. If we sort first (with merge sort) it will introduce another Θ(nlgn) time, that would change the constant in the final algorithm, but not the asymptotic time.<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">PAIR<span style="color: #333333;">-</span>EXISTS(S, x):
A <span style="color: #333333;">=</span> MERGE<span style="color: #333333;">-</span>SORT(S)
<span style="color: #008800; font-weight: bold;">for</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to S<span style="color: #333333;">.</span>length
<span style="color: #008800; font-weight: bold;">if</span> BINARY<span style="color: #333333;">-</span>SEARCH(A, x <span style="color: #333333;">-</span> S[i]) <span style="color: #333333;">!=</span> NIL
<span style="color: #008800; font-weight: bold;">return</span> true
<span style="color: #008800; font-weight: bold;">return</span> false
</pre>
</div>
<br />
<br /></div>
</div>
</div>
</div>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-44674107139956517072017-03-20T06:46:00.001-07:002017-03-20T06:47:31.858-07:00Chapter 2 Exercise 2.2, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<b>2.2-1 Express the function <span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><msup><mi>n</mi><mn>3</mn></msup><mrow class="MJX-TeXAtom-ORD"><mo>/</mo></mrow><mn>1000</mn><mo>&#x2212;</mo><mn>100</mn><msup><mi>n</mi><mn>2</mn></msup><mo>&#x2212;</mo><mn>100</mn><mi>n</mi><mo>+</mo><mn>3</mn></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-459"><span class="mjx-mrow" id="MJXc-Node-460"><span class="mjx-msubsup" id="MJXc-Node-461"><span class="mjx-base"><span class="mjx-mi" id="MJXc-Node-462"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span></span><span class="mjx-sup" style="font-size: 70.7%; padding-left: 0px; padding-right: 0.071em; vertical-align: 0.584em;"><span class="mjx-mn" id="MJXc-Node-463"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">3</span></span></span></span><span class="mjx-texatom" id="MJXc-Node-464"><span class="mjx-mrow" id="MJXc-Node-465"><span class="mjx-mo" id="MJXc-Node-466"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;">/</span></span></span></span><span class="mjx-mn" id="MJXc-Node-467"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">1000</span></span><span class="mjx-mo MJXc-space2" id="MJXc-Node-468"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.424em; padding-top: 0.29em;">−</span></span><span class="mjx-mn MJXc-space2" id="MJXc-Node-469"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">100</span></span><span class="mjx-msubsup" id="MJXc-Node-470"><span class="mjx-base"><span class="mjx-mi" id="MJXc-Node-471"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span></span><span class="mjx-sup" style="font-size: 70.7%; padding-left: 0px; padding-right: 0.071em; vertical-align: 0.584em;"><span class="mjx-mn" id="MJXc-Node-472"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.347em; padding-top: 0.386em;">2</span></span></span></span><span class="mjx-mo MJXc-space2" id="MJXc-Node-473"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.424em; padding-top: 0.29em;">−</span></span><span class="mjx-mn MJXc-space2" id="MJXc-Node-474"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">100</span></span><span class="mjx-mi" id="MJXc-Node-475"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span><span class="mjx-mo MJXc-space2" id="MJXc-Node-476"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.424em; padding-top: 0.29em;">+</span></span><span class="mjx-mn MJXc-space2" id="MJXc-Node-477"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">3 in terms of </span></span></span></span></span></span></b><br />
<b><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo>&#x2212;</mo><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-492"><span class="mjx-mrow" id="MJXc-Node-493"><span class="mjx-mi" id="MJXc-Node-494"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.482em;">θ</span></span><span class="mjx-mo MJXc-space2" id="MJXc-Node-495"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.424em; padding-top: 0.29em;">−</span></span><span class="mjx-mi MJXc-space2" id="MJXc-Node-496"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span><span class="mjx-mi" id="MJXc-Node-497"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">o</span></span><span class="mjx-mi" id="MJXc-Node-498"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.405em;">t</span></span><span class="mjx-mi" id="MJXc-Node-499"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">a</span></span><span class="mjx-mi" id="MJXc-Node-500"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.405em;">t</span></span><span class="mjx-mi" id="MJXc-Node-501"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.444em;">i</span></span><span class="mjx-mi" id="MJXc-Node-502"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">o</span></span><span class="mjx-mi" id="MJXc-Node-503"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n.</span></span></span></span></span></span></b><br />
<br />
<b><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo>&#x2212;</mo><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-492"><span class="mjx-mrow" id="MJXc-Node-493"><span class="mjx-mi" id="MJXc-Node-503"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">Solution:</span></span></span></span></span></span></b><br />
The leading term of the function ignoring the constant coefficient is <span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><msup><mi>n</mi><mn>3</mn></msup></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-504"><span class="mjx-mrow" id="MJXc-Node-505"><span class="mjx-msubsup" id="MJXc-Node-506"><span class="mjx-base"><span class="mjx-mi" id="MJXc-Node-507"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span></span><span class="mjx-sup" style="font-size: 70.7%; padding-left: 0px; padding-right: 0.071em; vertical-align: 0.584em;"><span class="mjx-mn" id="MJXc-Node-508"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">3</span></span></span></span></span></span></span></span> . So, the function in <span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo>&#x2212;</mo><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-492"><span class="mjx-mrow" id="MJXc-Node-493"><span class="mjx-mi" id="MJXc-Node-494"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.482em;">θ</span></span><span class="mjx-mo MJXc-space2" id="MJXc-Node-495"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.424em; padding-top: 0.29em;">−</span></span><span class="mjx-mi MJXc-space2" id="MJXc-Node-496"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span><span class="mjx-mi" id="MJXc-Node-497"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">o</span></span><span class="mjx-mi" id="MJXc-Node-498"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.405em;">t</span></span><span class="mjx-mi" id="MJXc-Node-499"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">a</span></span><span class="mjx-mi" id="MJXc-Node-500"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.405em;">t</span></span><span class="mjx-mi" id="MJXc-Node-501"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.444em;">i</span></span><span class="mjx-mi" id="MJXc-Node-502"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">o</span></span><span class="mjx-mi" id="MJXc-Node-503"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n </span></span></span></span></span></span>will be <span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-516"><span class="mjx-mrow" id="MJXc-Node-517"><span class="mjx-mi" id="MJXc-Node-518"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.482em;">θ</span></span><span class="mjx-mo" id="MJXc-Node-519"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;">(</span></span><span class="mjx-msubsup" id="MJXc-Node-520"><span class="mjx-base"><span class="mjx-mi" id="MJXc-Node-521"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span></span><span class="mjx-sup" style="font-size: 70.7%; padding-left: 0px; padding-right: 0.071em; vertical-align: 0.584em;"><span class="mjx-mn" id="MJXc-Node-522"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.367em; padding-top: 0.386em;">3</span></span></span></span><span class="mjx-mo" id="MJXc-Node-523"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;">).</span></span></span></span></span></span><br />
<b><br /></b>
<b><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-516"><span class="mjx-mrow" id="MJXc-Node-517"><span class="mjx-mo" id="MJXc-Node-523"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;">2.2-2 Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[1]. Then find the second smallest element of A, and exchange it with A[2]. Continue in this manner for the first n 1elements of A. Write pseudocode for this algorithm, which is known as selection sort. What loop invariant does this algorithm maintain? Why does it need to run for only the first n 1 elements, rather than for all n elements? Give the best-case and worst-case running times of selection sort in </span></span></span></span></span></span><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-516"><span class="mjx-mrow" id="MJXc-Node-517"><span class="mjx-mo" id="MJXc-Node-523"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;"><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo>&#x2212;</mo><mi>n</mi><mi>o</mi><mi>t</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-492"><span class="mjx-mrow" id="MJXc-Node-493"><span class="mjx-mi" id="MJXc-Node-494"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.482em;">θ</span></span><span class="mjx-mo MJXc-space2" id="MJXc-Node-495"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.424em; padding-top: 0.29em;">−</span></span><span class="mjx-mi MJXc-space2" id="MJXc-Node-496"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span><span class="mjx-mi" id="MJXc-Node-497"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">o</span></span><span class="mjx-mi" id="MJXc-Node-498"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.405em;">t</span></span><span class="mjx-mi" id="MJXc-Node-499"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">a</span></span><span class="mjx-mi" id="MJXc-Node-500"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.405em;">t</span></span><span class="mjx-mi" id="MJXc-Node-501"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.444em;">i</span></span><span class="mjx-mi" id="MJXc-Node-502"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">o</span></span><span class="mjx-mi" id="MJXc-Node-503"><span class="mjx-char MJXc-TeX-math-I" style="padding-bottom: 0.29em; padding-top: 0.213em;">n</span></span></span></span></span></span>? Justify your answers.</span></span></span></span></span></span></b><br />
<br />
<b><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-516"><span class="mjx-mrow" id="MJXc-Node-517"><span class="mjx-mo" id="MJXc-Node-523"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;">Solution: </span></span></span></span></span></span></b><br />
<br />
<b><span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-516"><span class="mjx-mrow" id="MJXc-Node-517"><span class="mjx-mo" id="MJXc-Node-523"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;">Pseudocode</span></span></span></span></span></span></b><br />
<span class="mjx-chtml MJXc-display" style="text-align: center;"><span class="mjx-chtml MathJax_CHTML" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi>&#x03B8;</mi><mo stretchy="false">(</mo><msup><mi>n</mi><mn>3</mn></msup><mo stretchy="false">)</mo></math>" id="MathJax-Element-10-Frame" role="presentation" style="font-size: 116%; position: relative; text-align: center;" tabindex="0"><span class="mjx-math" id="MJXc-Node-516"><span class="mjx-mrow" id="MJXc-Node-517"><span class="mjx-mo" id="MJXc-Node-523"><span class="mjx-char MJXc-TeX-main-R" style="padding-bottom: 0.597em; padding-top: 0.463em;"><br /></span></span></span></span></span></span>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">SELECTION<span style="color: #333333;">-</span>SORT(A):
<span style="color: #008800; font-weight: bold;">for</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span> to A<span style="color: #333333;">.</span>length <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #007020;">min</span> <span style="color: #333333;">=</span> i
<span style="color: #008800; font-weight: bold;">for</span> j <span style="color: #333333;">=</span> i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span> to A<span style="color: #333333;">.</span>length
<span style="color: #008800; font-weight: bold;">if</span> A[j] <span style="color: #333333;"><</span> A[<span style="color: #007020;">min</span>]
<span style="color: #007020;">min</span> <span style="color: #333333;">=</span> j
temp <span style="color: #333333;">=</span> A[i]
A[i] <span style="color: #333333;">=</span> A[<span style="color: #007020;">min</span>]
A[<span style="color: #007020;">min</span>] <span style="color: #333333;">=</span> temp
</pre>
</div>
<br />
<b>Loop invariants</b><br />
<br />
At the start of each iteration of the inner for loop, A[min] is the smallest number in the subarray A[i..j−1].<br />
<br />
<b>Why n−1 elements?</b><br />
In the final step, the algorithm will be left with two elements to compare. It will store the smaller one in A[n−1] and leave the larger in A[n]. The final one will be the largest element of the array, since all the previous iteration would have sorted all but the last two elements (the outer loop invariant). If we do it n times, we will end up with a redundant step that sorts a single-element subarray.<br />
<br />
<b>Running times</b><br />
In the best-case time (the array is sorted), the body of the if is never invoked. The number of operations (counting the comparison as one operation) is:<br />
<div style="text-align: center;">
$$ (n - 1)(\frac{n + 2}{2} + 4) $$<br />
<div style="text-align: left;">
In the worst-case time (the array is reversed), the body of the if is invoked on every occasion, which doubles the number of steps in the inner loop, that is:</div>
<div style="text-align: center;">
(n-1)(n+6)</div>
<div style="text-align: left;">
Both are clearly Θ(n2). </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>2.2-3 Consider linear search again (see Exercise 2.1-3). How many elements of the input sequence need to be checked on the average, assuming that the element being searched for is equally likely to be any element in the array? How about in the worst case? What are the average-case and worst-case running times of linear search in ‚Θ-notation? Justify your answers.</b></div>
<div style="text-align: left;">
<b><br /></b></div>
<div style="text-align: left;">
<b>Solution:</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
If the element is present in the sequence, half of the elements are likely to be checked before it is found in the average case. In the worst case, all of them will be checked. That is, n/2 checks for the average case and n for the worst case. Both of them are Θ(n).</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>2.2-4 How can we modify almost any algorithm to have a good best-case running time?</b></div>
<div style="text-align: left;">
<b><br /></b></div>
<div style="text-align: left;">
<b>Solution:</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
We can modify it to handle the best-case efficiently. For example, if we modify merge-sort to check if the array is sorted and just return it, the best-case running time will be Θ(n).</div>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-58660952069188776512017-03-17T03:32:00.001-07:002017-03-20T06:54:45.349-07:00Chapter 2 Exercise 2.1, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<a href="https://www.blogger.com/blogger.g?blogID=619838397038898011" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=619838397038898011" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><b>2.1-1
Using Figure 2.2 as a model, illustrate the operation of
INSERTION -SORT on the
array <span style="font-family: "liberation" serif , serif;"><i>A</i></span><span style="font-family: "liberation" serif , serif;">=⟨31,41,59,26,41,58⟩.</span></b>
<br />
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-family: "liberation" serif , serif;">Solution:</span></b></div>
<br />
<img alt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAl0AAAJFCAYAAADnB0LdAABQDElEQVR4nO3de4xUxb73/yJ5kJsGgRFhBhUTEIRtgIS9AefIRRAwyAESZlAhAgoqCgECCoKRSwBRmS1kjwoHjihBxcEEOHJEBOSyw2UUA0RQ2GAgOiAgKERuHv/4/Z5PPc/qZ3XTc2G6u1b36vcr6czQ084sq7tXfVbVt6r/1//3vxkAAACk1P8K+gAAAACyAaELAADAAUIXAACAA4QuAAAABwhdAAAADhC6AAAAHCB0AQAAOEDoAgAAcIDQBQAA4AChCwAAwAFCFwAAgAOELgAAAAcIXQAAAA4QugAAABxIKHSNGzfOFBcXJ+tYAAAA0lZeXp4pKyur9n+fUOg6c+aMyc/PN+PHj0/k1wAAAKS10tJSU1RUlNDvSHh6MTc31xQUFCT6awAAAEKNmi4AAAAHCF0AAAAOELoAAAAcIHQBAAA4QOgCA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0KbShS2+yzp07m06dOtknWm+4jh07mq+//vq6x+qFMWvWLPvknzt3jjddCsyfP98cOXIkbuhS2Fq5cqU5duyY+fTTTwldSdK2bVvbnn4ffPBBVOD6xz/+YWrXrm0mTJhgmjdvbj7++GMbyvR+QfXptawgW6dOHfu9vPbaazbUNmvW7LrHr1692p6D9DxMmjTJ9eGGnjp6tX280MX5PzV08da/f/+o+4YOHRrVvpMnT7b9s/oHhbNp06bZ+0tKSpweq0uhDV0fffSR2bNnj2nUqJH9t95UM2fOtIm6W7dukceVlZWZ9u3b2ytLvemQfOr4NdoYz9mzZ02bNm3MXXfdFemckBzqwDW6q5EWz4ULFyLfFxQUmLFjx5rbbrvNBjGdJKdOnWqfr3379pmdO3cGcdihMHHiRLNx40YbfHUBqHZdtmyZPQ8tXbo06rHqeBR0S0tL7eORXGp3vZ7j4fyfOgsXLjSbNm2yo7yehg0bRr5XexcVFZmffvrJXojoNm/ePNOyZUuzefPmSmemMlVoQ1ffvn0jgUueeuopG7pycnKiHudddeoqH8mnk5pGuO6//357pRmrcePG9qumvZA8eXl5tjPRa/7kyZNxH/P000/boKure48uVEQhIfYqFVWjzuTRRx+NBCidhzTCos5/9+7dUY/VCJc6HgUxAlfy6fV94MABO231/vvvX/dzzv+pofP+/v377es+3siuHD9+3H7VRaH3GI26y7Vr19wcaABCG7pi54X1AlCNBCc2d/7880+zfPlyO+KyYsWKoA8nq4wePdpOp+vkp45HU1vq9P10BRp7clMA0+O7dOni8nBD5e6777Zt76dORffVqlUrcp+em+eee84G5FGjRrk+zKyg6SrV9b7yyitBH0pW0citLj7uuOMO2xdPmTLlutd4v379TL169cxLL71kOnToYC9OVN6gPlq1dWEV2tDl59VLfP7550EfSlbRyW7gwIHmlltuCfpQss4///lPO4Kijl7T6RpJGTJkiHnooYcij1Hg0glRJz5/nZemguPdj6rxj7D7/fzzzzYMe3Q+Usjt2bOnKSwsNLt27bL3jxgxwsyZM8fJsYbZyy+/bJ5//nlqtAKgekadXzRyrjIFve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z1Wb0y1vd582miR0JV88+fPN0eOHIkbuhQMVq5cad8nn376KaErScrKyszMmTOj7uvZs2dU+7711lvm6tWrZvz48TaQTZkyxQwaNMgMHjzY8dGG29tvv20v6OKFLoWtGTNm2PPTbbfdRuhKEm2o279//6j7hg4dGnV+nzx5su0fdH5SOJs2bZq9v6SkxOmxuhTa0DVx4kSzceNG+/EUCgBTp041y5Yts5370qVLox6rJ16fD1ZaWlrpx1mgaj766COzZ88eu7+PqN3VAemKplu3bpHHqWNq3769HVlU6ELyKUhptDEebWypDya+6667IhcnSI5Vq1bZjUW107unQYMGke8VdnWx5wVdXQzqvKXzkd4P9913XxCHXSG9RrQxal5ensnNzc2ICyRta1HeXmL6/9i3b5+9IFHoQvIsXLjQbNq0KeoDzxs2bBj5Xuf7oqIi89NPP9nXvm7z5s2zI72bN2+udGYkU4UydOnJfPTRRyMBSh2/rmQUunbv3h31WJ309MQriBG4kqdv376RwCVPPfWUDV0a5vfzRh2bN2/u8vCyhkKtOpT777/fjvLGaty4sf3apEkT14cWagqzx48fN0888USkjWNphFed/i233BK5T2FLFNjSMXT98ccf9quCl2716tWzr514swfpQFNVmrLV1PqIESOu+7m3sz4XHMml887+/fttv1vea0PvD1H5j/cYTbHLtWvX3BxoAEIZuu6+++7rrlr0pOq+WrVqRe7TC+O5556zJz42+Uuu2Hl5vQE1jE+wdUe1RMuXL7dT5itWrAj6cLKKOnlNrxQWFtrziy4CdSHin1rU6KP/fCQKYHq83i+ZQFNxP/zwg72lYwDTyMnIkSPtSDvc0cyRBj/uuOMO2xdo2jy2j+3Xr599zbz00kt2JFIX6R9//LHtIzQVHFahDF3+ERa/n3/+2YwePTryb32Qq2qIVGehk6M+4FV0RTRnzhwnx5oNvHo5tTfc0SKGgQMHRo2kwA1vOkvhSeFLo+maWn/11VcjwUuBSyMtWuTgf46aNm0a9/505w9gGtFWACvvXOyCRtYXLVpEjVYAVE+t0SqVmOzcudP2uxq91bShR1PT6hc0na76Xy0w0YWI3ieZMG1d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H9t95UM2fOtIm6W7dukceVlZWZ9u3b2ytLvemQfOr4NdoYz9mzZ02bNm3MXXfdFemckBzqwDW6q5EWz4ULFyLfFxQUmLFjx5rbbrvNBjGdJKdOnWqfr3379pmdO3cGcdihMHHiRLNx40YbfHUBqHZdtmyZPQ8tXbo06rHqeBR0S0tL7eORXGp3vZ7j4fyfOgsXLjSbNm2yo7yehg0bRr5XexcVFZmffvrJXojoNm/ePNOyZUuzefPmSmemMlVoQ1ffvn0jgUueeuopG7pycnKiHudddeoqH8mnk5pGuO6//357pRmrcePG9qumvZA8eXl5tjPRa/7kyZNxH/P000/boKure48uVEQhIfYqFVWjzuTRRx+NBCidhzTCos5/9+7dUY/VCJc6HgUxAlfy6fV94MABO231/vvvX/dzzv+pofP+/v377es+3siuHD9+3H7VRaH3GI26y7Vr19wcaABCG7pi54X1AlCNBCc2d/7880+zfPlyO+KyYsWKoA8nq4wePdpOp+vkp45HU1vq9P10BRp7clMA0+O7dOni8nBD5e6777Zt76dORffVqlUrcp+em+eee84G5FGjRrk+zKyg6SrV9b7yyitBH0pW0citLj7uuOMO2xdPmTLlutd4v379TL169cxLL71kOnToYC9OVN6gPlq1dWEV2tDl59VLfP7550EfSlbRyW7gwIHmlltuCfpQss4///lPO4Kijl7T6RpJGTJkiHnooYcij1Hg0glRJz5/nZemguPdj6rxj7D7/fzzzzYMe3Q+Usjt2bOnKSwsNLt27bL3jxgxwsyZM8fJsYbZyy+/bJ5//nlqtAKgekadXzRyrjIFve5XrVplpw09el7UL2t6XfXXOj/p3KMSoDA/Z6EOXVoNNH78eFvfpc5DaXrDhg3XXYUi+b799ltbRHzfffcFfShZacuWLfYmunLUFaRqJKZPn27mzp1r71enr5quHj162GJiz6233mrrkAhcyeOtznrhhRci96mGSzQV6Y0CKCjo+VGHtWDBAvcHGhJqby3I8dfvwh2da7yaLNWKKlDpfKSQ5V/M4C0aUfDS614Xh+VdtIRFqEOX0rKeRN101a8nVqtY4q1gRPJoewhd1aieCMHTSU+reF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AAc+P8B/S3xOy1eg3wAAAAASUVORK5CYII=" /><br />
<br />
<div style="line-height: 100%; margin-bottom: 0in;">
<b>2.1-2
Rewrite the INSERTION -SORT procedure to sort into nonincreasing
instead of non-decreasing order.</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Solution:</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
Insertion-Sort(A)<b> </b></div>
<pre><code class="language-java" data-lang="java"><pre><a href="https://www.blogger.com/blogger.g?blogID=619838397038898011" imageanchor="1" style="margin-left: 1em; margin-right: 1em;">
</a></pre>
</code><code class="language-java" data-lang="java"><pre><a href="https://www.blogger.com/blogger.g?blogID=619838397038898011" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=619838397038898011" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><span class="k">for</span> <span class="n">j</span> <span class="o">=</span> <span class="mi">2</span> <span class="n">to</span> <span class="n">A</span><span class="o">.</span><span class="na">length</span>
<span class="n">key</span> <span class="o">=</span> <span class="n">A</span><span class="o">[</span><span class="n">j</span><span class="o">]</span>
<span class="c1">// Insert A[j] into the sorted sequence A[1..j − 1]</span>
<span class="n">i</span> <span class="o">=</span> <span class="n">j</span> <span class="err">−</span> <span class="mi">1</span>
<span class="k">while</span> <span class="n">i</span> <span class="o">></span> <span class="mi">0</span> <span class="n">and</span> <span class="n">A</span><span class="o">[</span><span class="n">i</span><span class="o">]</span> <span class="o"><</span> <span class="n">key</span>
<span class="n">A</span><span class="o">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="o">]</span> <span class="o">=</span> <span class="n">A</span><span class="o">[</span><span class="n">i</span><span class="o">]</span>
<span class="n">i</span> <span class="o">=</span> <span class="n">i</span> <span class="err">−</span> <span class="mi">1</span>
<span class="n">A</span><span class="o">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="o">]</span> <span class="o">=</span> <span class="n">key</span></pre>
</code><code class="language-java" data-lang="java">
</code></pre>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>2.1-3
Consider
the searching problem:
</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Input: A sequence
of n numbers A=<a</b><sub><b>1</b></sub><b>,a</b><sub><b>2</b></sub><b>,...,a</b><sub><b>n</b></sub><b>>
and a value v.</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Output: An index
i such that
v=A[i] or the special value NIL if v does not appear in
A.</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Write pseudocode
for linear search, which scans through the sequence, looking
for v.
Using a loop invariant, prove that your algorithm is correct. Make
sure that
your loop invariant fulfills the three necessary
properties.</b></div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-family: "liberation" serif , serif;">Solution:</span></b></div>
<pre><code class="language-java" data-lang="java"></code></pre>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<pre><code class="language-java" data-lang="java"><pre><span class="k">Linear-Search(A,v): </span></pre>
<pre><span class="k">for</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">to</span> <span class="n">A</span><span class="o">.</span><span class="na">length</span>
<span class="k">if</span> <span class="n">A</span><span class="o">[</span><span class="n">i</span><span class="o">]</span> <span class="o">==</span> <span class="n">v</span>
<span class="k">return</span> <span class="n">i</span>
<span class="k">return</span> <span class="n">NIL</span><span class="w"></span></pre>
</code></pre>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Initialization:</b> Initially the subarray is empty. So,
none of its’ elements are equal to <span style="font-family: "mathjax math";"><i>v</i></span>.
</div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<a href="https://www.blogger.com/null" name="MathJax-Element-13-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-65"></a><a href="https://www.blogger.com/null" name="MathJax-Span-66"></a><a href="https://www.blogger.com/null" name="MathJax-Span-67"></a><a href="https://www.blogger.com/null" name="MathJax-Element-14-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-68"></a><a href="https://www.blogger.com/null" name="MathJax-Span-69"></a><a href="https://www.blogger.com/null" name="MathJax-Span-70"></a><a href="https://www.blogger.com/null" name="MathJax-Span-71"></a><a href="https://www.blogger.com/null" name="MathJax-Span-72"></a><a href="https://www.blogger.com/null" name="MathJax-Span-73"></a><a href="https://www.blogger.com/null" name="MathJax-Element-15-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-74"></a><a href="https://www.blogger.com/null" name="MathJax-Span-75"></a><a href="https://www.blogger.com/null" name="MathJax-Span-76"></a><a href="https://www.blogger.com/null" name="MathJax-Element-16-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-77"></a><a href="https://www.blogger.com/null" name="MathJax-Span-78"></a><a href="https://www.blogger.com/null" name="MathJax-Span-79"></a><a href="https://www.blogger.com/null" name="MathJax-Span-80"></a><a href="https://www.blogger.com/null" name="MathJax-Span-81"></a><a href="https://www.blogger.com/null" name="MathJax-Span-82"></a><a href="https://www.blogger.com/null" name="MathJax-Span-83"></a><a href="https://www.blogger.com/null" name="MathJax-Span-84"></a><a href="https://www.blogger.com/null" name="MathJax-Span-85"></a><a href="https://www.blogger.com/null" name="MathJax-Element-17-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-86"></a><a href="https://www.blogger.com/null" name="MathJax-Span-87"></a><a href="https://www.blogger.com/null" name="MathJax-Span-88"></a><a href="https://www.blogger.com/null" name="MathJax-Element-18-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-89"></a><a href="https://www.blogger.com/null" name="MathJax-Span-90"></a><a href="https://www.blogger.com/null" name="MathJax-Span-91"></a><a href="https://www.blogger.com/null" name="MathJax-Element-19-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-92"></a><a href="https://www.blogger.com/null" name="MathJax-Span-93"></a><a href="https://www.blogger.com/null" name="MathJax-Span-94"></a><a href="https://www.blogger.com/null" name="MathJax-Span-95"></a><a href="https://www.blogger.com/null" name="MathJax-Span-96"></a><a href="https://www.blogger.com/null" name="MathJax-Span-97"></a><a href="https://www.blogger.com/null" name="MathJax-Span-98"></a><a href="https://www.blogger.com/null" name="MathJax-Element-20-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-99"></a><a href="https://www.blogger.com/null" name="MathJax-Span-100"></a><a href="https://www.blogger.com/null" name="MathJax-Span-101"></a><a href="https://www.blogger.com/null" name="MathJax-Element-21-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-102"></a><a href="https://www.blogger.com/null" name="MathJax-Span-103"></a><a href="https://www.blogger.com/null" name="MathJax-Span-104"></a>
<b>Maintenance:</b> In <span style="font-family: "mathjax math";"><i>i</i></span>-th
iteration, we check whether <span style="font-family: "mathjax math";"><i>A</i></span><span style="font-family: "mathjax main";">[</span><span style="font-family: "mathjax math";"><i>i</i></span><span style="font-family: "mathjax main";">]</span>
is equal to <span style="font-family: "mathjax math";"><i>v</i></span> or not. If yes,
we terminate the loop or we continue the iteration. So, if the
subarray <span style="font-family: "mathjax math";"><i>A</i></span><span style="font-family: "mathjax main";">[1..</span><span style="font-family: "mathjax math";"><i>i</i></span>−<span style="font-family: "mathjax main";">1]</span>
did not contain <span style="font-family: "mathjax math";"><i>v</i></span> before the
<span style="font-family: "mathjax math";"><i>i</i></span>-th iteration, the subarray
<span style="font-family: "mathjax math";"><i>A</i></span><span style="font-family: "mathjax main";">[1..</span><span style="font-family: "mathjax math";"><i>i</i></span><span style="font-family: "mathjax main";">]</span>
will not contain <span style="font-family: "mathjax math";"><i>v</i></span> before the
next iteration (unless <span style="font-family: "mathjax math";"><i>i</i></span>-th
iteration terminates the loop).</div>
<div style="font-weight: normal;">
<b>Termination:</b> The loop
terminates in either of the following cases,</div>
<ul>
<li><a href="https://www.blogger.com/null" name="MathJax-Element-23-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-108"></a><a href="https://www.blogger.com/null" name="MathJax-Span-109"></a><a href="https://www.blogger.com/null" name="MathJax-Span-110"></a><a href="https://www.blogger.com/null" name="MathJax-Element-24-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-111"></a><a href="https://www.blogger.com/null" name="MathJax-Span-112"></a><a href="https://www.blogger.com/null" name="MathJax-Span-113"></a><a href="https://www.blogger.com/null" name="MathJax-Span-114"></a>
We have found index i<span style="font-family: "mathjax math";"><i> </i></span>such
that <span style="font-family: "mathjax math";"><i>v</i></span> = <span style="font-family: "mathjax math";"><i>A</i></span><sub><span style="font-family: "mathjax math";"><i>i</i></span></sub><br />
</li>
<li><a href="https://www.blogger.com/null" name="MathJax-Element-25-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-116"></a><a href="https://www.blogger.com/null" name="MathJax-Span-117"></a><a href="https://www.blogger.com/null" name="MathJax-Span-118"></a><a href="https://www.blogger.com/null" name="MathJax-Element-26-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-119"></a><a href="https://www.blogger.com/null" name="MathJax-Span-120"></a><a href="https://www.blogger.com/null" name="MathJax-Span-121"></a><a href="https://www.blogger.com/null" name="MathJax-Element-27-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-122"></a><a href="https://www.blogger.com/null" name="MathJax-Span-123"></a><a href="https://www.blogger.com/null" name="MathJax-Span-124"></a>
We reached the end of the array, i.e. we did not find <span style="font-family: "mathjax math";"><i>v</i></span>
in the array <span style="font-family: "mathjax math";"><i>A</i></span>. So, we
return <span style="font-family: "mathjax main";">NIL</span><br />
</li>
</ul>
In either case, our algorithm does exactly what was required,
which means the algorithm is correct.<br />
<br />
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-family: "liberation" serif , serif;">2.1-4
Consider the problem of adding two n-bit binary integers, stored in
two n-element
arrays A and B. The sum of the two integers should be
stored in binary form in an .n C 1/-element array C . State the
problem formally and write pseudocode for
adding the two integers.</span></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-family: "liberation" serif , serif;">Solution:</span></b></div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<a href="https://www.blogger.com/null" name="MathJax-Element-7-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-23"></a><a href="https://www.blogger.com/null" name="MathJax-Span-24"></a><a href="https://www.blogger.com/null" name="MathJax-Span-25"></a><a href="https://www.blogger.com/null" name="MathJax-Element-8-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-26"></a><a href="https://www.blogger.com/null" name="MathJax-Span-27"></a><a href="https://www.blogger.com/null" name="MathJax-Span-28"></a>
<b>Input:</b> Two <span style="font-family: "mathjax math";"><i>n</i></span>-bit
binary integers stored in two <span style="font-family: "mathjax math";"><i>n</i></span>-element
array of binary digits (either 0 or 1)
</div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
A=<a<sub>1</sub>,a<sub>2</sub>,...,a<sub>n</sub>> and
B=<b<sub>1</sub>,b<sub>2</sub>,...,b<sub>n</sub>>.</div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<a href="https://www.blogger.com/null" name="MathJax-Element-11-Frame"></a><a href="https://www.blogger.com/null" name="MathJax-Span-711"></a><a href="https://www.blogger.com/null" name="MathJax-Span-721"></a><a href="https://www.blogger.com/null" name="MathJax-Span-731"></a><a href="https://www.blogger.com/null" name="MathJax-Span-741"></a><a href="https://www.blogger.com/null" name="MathJax-Span-751"></a><a href="https://www.blogger.com/null" name="MathJax-Span-761"></a><a href="https://www.blogger.com/null" name="MathJax-Span-771"></a><a href="https://www.blogger.com/null" name="MathJax-Element-12-Frame1"></a><a href="https://www.blogger.com/null" name="MathJax-Span-781"></a><a href="https://www.blogger.com/null" name="MathJax-Span-791"></a><a href="https://www.blogger.com/null" name="MathJax-Span-801"></a><a href="https://www.blogger.com/null" name="MathJax-Span-811"></a><a href="https://www.blogger.com/null" name="MathJax-Span-821"></a><a href="https://www.blogger.com/null" name="MathJax-Span-831"></a><a href="https://www.blogger.com/null" name="MathJax-Span-841"></a><a href="https://www.blogger.com/null" name="MathJax-Element-13-Frame1"></a><a href="https://www.blogger.com/null" name="MathJax-Span-851"></a><a href="https://www.blogger.com/null" name="MathJax-Span-861"></a><a href="https://www.blogger.com/null" name="MathJax-Span-871"></a><a href="https://www.blogger.com/null" name="MathJax-Span-881"></a><a href="https://www.blogger.com/null" name="MathJax-Span-891"></a><a href="https://www.blogger.com/null" name="MathJax-Span-901"></a><a href="https://www.blogger.com/null" name="MathJax-Span-911"></a><a href="https://www.blogger.com/null" name="MathJax-Span-921"></a><a href="https://www.blogger.com/null" name="MathJax-Span-931"></a><a href="https://www.blogger.com/null" name="MathJax-Span-941"></a><a href="https://www.blogger.com/null" name="MathJax-Span-951"></a><a href="https://www.blogger.com/null" name="MathJax-Span-961"></a><a href="https://www.blogger.com/null" name="MathJax-Span-971"></a><a href="https://www.blogger.com/null" name="MathJax-Span-981"></a><a href="https://www.blogger.com/null" name="MathJax-Span-991"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1001"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1011"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1021"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1031"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1041"></a><a href="https://www.blogger.com/null" name="MathJax-Span-105"></a><a href="https://www.blogger.com/null" name="MathJax-Span-106"></a><a href="https://www.blogger.com/null" name="MathJax-Span-107"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1081"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1091"></a><a href="https://www.blogger.com/null" name="MathJax-Element-14-Frame1"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1101"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1111"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1121"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1131"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1141"></a><a href="https://www.blogger.com/null" name="MathJax-Span-115"></a><a href="https://www.blogger.com/null" name="MathJax-Span-1161"></a>
<b>Output:</b> A <span style="font-family: "mathjax main";">(</span><span style="font-family: "mathjax math";"><i>n</i></span><span style="font-family: "mathjax main";">+1)</span>-bit
binary integer stored in <span style="font-family: "mathjax main";">(</span><span style="font-family: "mathjax math";"><i>n</i></span><span style="font-family: "mathjax main";">+1)</span>-element
array of binary digits (either 0 or 1) <span style="font-family: "mathjax math";"><i>C</i></span><span style="font-family: "mathjax main";">=</span>⟨<span style="font-family: "mathjax math";"><i>c</i></span><sub><span style="font-family: "mathjax main";">1</span></sub><span style="font-family: "mathjax main";">,</span><span style="font-family: "mathjax math";"><i>c</i></span><sub><span style="font-family: "mathjax main";">2</span></sub><span style="font-family: "mathjax main";">,...,</span><span style="font-family: "mathjax math";"><i>c</i></span><sub><span style="font-family: "mathjax math";"><i>n</i></span></sub><span style="font-family: "mathjax main";">+1</span>⟩
such that <span style="font-family: "mathjax math";"><i>C</i></span><span style="font-family: "mathjax main";">=</span><span style="font-family: "mathjax math";"><i>A</i></span><span style="font-family: "mathjax main";">+</span><span style="font-family: "mathjax math";"><i>B</i></span>.</div>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<br /></div>
<pre><code class="language-cpp" data-lang="cpp"><pre><span class="n">Binary-Add(A,B): </span></pre>
<pre><a href="https://www.blogger.com/blogger.g?blogID=619838397038898011" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><span class="n">n</span> <span class="o">=</span> <span class="n">A</span><span class="p">.</span><span class="n">length</span>
<span class="k">for</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span> <span class="n">to</span> <span class="p">(</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">C</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">carry</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">for</span> <span class="n">i</span> <span class="o">=</span> <span class="n">n</span> <span class="n">to</span> <span class="mi">1</span>
<span class="n">C</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">carry</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span>
<span class="n">carry</span> <span class="o">=</span> <span class="p">(</span><span class="n">A</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">B</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">carry</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
<span class="n">C</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">carry</span>
<span class="k">return</span> <span class="n">C</span><span class="w"></span></pre>
</code></pre>
<div style="font-weight: normal; line-height: 100%; margin-bottom: 0in;">
<br /></div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com1tag:blogger.com,1999:blog-619838397038898011.post-20875000594965130002017-03-16T07:09:00.001-07:002017-03-16T07:09:57.786-07:00Chapter 1 Problems, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="line-height: 100%; margin-bottom: 0in;">
<strong><span style="font-style: normal;"><b>1-1
Comparison of running times
</b></span></strong>
</div>
<div style="line-height: 100%; margin-bottom: 0in;">
<strong><span style="font-style: normal;"><b>For
each function f(n) and time t in the following table, determine the
largest
size n of a problem that can be solved in time t, assuming
that the algorithm to
solve the problem takes f(n) microseconds.</b></span></strong></div>
<div style="font-style: normal; line-height: 100%; margin-bottom: 0in;">
<br />
</div>
<div style="line-height: 100%; margin-bottom: 0in;">
<strong><span style="font-style: normal;"><b>Solution:</b></span></strong></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br />
</div>
<table cellpadding="4" cellspacing="0" style="width: 708px;">
<colgroup><col width="65"></col>
<col width="66"></col>
<col width="66"></col>
<col width="103"></col>
<col width="103"></col>
<col width="125"></col>
<col width="82"></col>
<col width="33"></col>
</colgroup><tbody>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="65">
<br />
<br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="66">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
second
</span></span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="66">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
minute
</span></span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="103">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
hour</span></span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="103">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
day
</span></span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="125">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
month
</span></span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="82">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
year
</span></span></strong><br />
</td>
<td style="border: 1px solid #000000; padding: 0.04in;" width="33">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">1
century</span></span></strong><br />
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">lg
n</span></span></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<img height="21" hspace="8" name="Object5" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAVCAIAAADaYBkLAAACFUlEQVR4nGP5//8/A7UBC8Um/HtzcNbaVxIifAa+7gps1DH0/7sjS68ye/N/YmBhhIkRaeifV0dnlJZsc1yzOUGameHblells1/L8jy+L1vQF/SXWczI2fpy2fp7TrnqrEQb+v/7s8fsuir/1vwB8f693FS9UrFnd7Hc9Vr7ys1+UzxY12/a903dVBJmGFGGMnLKGev/3Av13o87e29y+4uxMrDLmQjc3HJfZHZFPqp6MsL077f3v9lZmYAsJnbOPx++/cVQgWroj0sdwVGz77FJiHL9ePOexyZ/Qk+KIR8TqhZmbiG2n7/+gYz//o1ViJuZgKG/X9/4k7jtYrE6G8O/9/uytJ1dvsrdWeIhyIisiEPFWe3LjZe/fTkenfmg7qLKQcBQDrW4MlVFcGJjEjQLd+CbuWf9je8eFv9v71m38uiTB9zLV6mEBjr4toQV9TW2CDx/m9juI8pEwFBWWSdnBO/f3/8MbFysjAyMXKqusTVABJPRzZ4xA8MoXIaiBMWL81c/i7j6q3Pi0U6ioV/OTp323K2z3oaXZDNxGPr31bbStMMBK3ckyJOTj7Ho+ftqZ3lor0DfjhYXEcxIIMfQ34/X5iesUO/fkGfEy4hVB6mG/n60JNaplSW3WenZwa3PwELMAlp21krcpJmPYuj3ays33L3xsyB0KUJMo+3GxUp1NvIN5fPY/IMa9QDlJT+9DAUAIl+/ej3/WGcAAAAASUVORK5CYII=" width="28" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<img height="21" hspace="8" name="Object6" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAVCAIAAAC7eDtJAAADCElEQVR4nGP5//8/w0AAFtpb8eV4S93G7wwv3li0TQuTYqafxTyWNX0mj7eveWMjyYwQJc7ifx9OTKpf/VFS6OvdHwETmq24MVT8eXV0RmnJNsc1mxOkmRm+XZleNvu1LM/j+7IF/RnanJ+vHPhpEc7LiKSBKIu/n++sux+6bqINz9/vH3+zw4T///r6nYmbC2jE/+/PHrPrqvxb8wfszJebqlcq9uwulrtea1+5KWiN9ekzcrbJbChmEmPxr/tbtz96zzWlcePD5wKBjRVuHAz/vr16+//fvpQG0endmv/YJYXkjPV/7oX66MedvTe5/cVYGdjlTARubrn9J9w7VQbdUGIs/vPx2Xdpn6zyMMHnC92c6x3PzrBifLi5pfvst0+vGEvzRDybGoNkWRHq/357/5udlQnIYmLn/PPh219shqJa/ONSR3DU7HtsEqJcP96857HJn9CTYsjHzC3M/v3Nl38MwgKqSn8XPfn+n4FPQEVT4uze6+9YFfXt5HmYUExh5hZi+/nrH8gJ37+xCnEzM2ABqBb/fn3jT+K2i8XqbAz/3u/L0nZ2+Sp3Z4mHgqPh1/k3vmTJM37+wKkszQEM0v/M6gkV4s/7Bcv9f79GKwk4VJzVvtx4+duX49GZD+ouqhyELeZQiytTVQSnAiZBs3AHvpl71t/47mFp31K7rbyq8TTnfYnSelNQmpaycWT48SQngUNSX0SW4f/X27vXrTz65AH38lUqoYEOvi1hRX2NLQLP3ya2+4gyEbaYVdbJGcH79/c/AxsXKyNIPKRvWQi6Xg4ZY30Ii5Fb1TW2BohgUrrZM2Zgsw6Xxcjg94vzVz+LuPqrc+I3gUyA0+IvZ6dOe+7WWW/DSxN7cVj899W20rTDASt3JMjTqkzFYu7fVzvLQ3sF+na0uIhgTRc0sfj347X5CSvU+zfkGaEUrbS1+PejJbFOrSy5zUrPDm59BhZiFtCys1bipr4bUCz+fm3lhrs3fhaELkWIabTduFipzoauj7oW83ls/kGv9ggdGgKDzGIAWmAm9AFQjLsAAAAASUVORK5CYII=" width="40" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<img height="21" hspace="8" name="Object7" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAVCAIAAACyk5szAAADcUlEQVR4nGP5//8/w0ADFrrb+OV4S93G7wwv3li0TQuTYh4YR/BY1vSZPN6+5o2NJDNUiChHfDlUkLCE20Di3dmb8pWzy814Pp6YVL/6o6TQ17s/AiY0W3Fj6Pjz6uiM0pJtjms2J0gzM3y7Mr1s9mtZnsf3ZQv6M7Q5P1858NMinJcRppooRzCLu1d1eRgJfNziZ9RzKnuhYGfd/dB1E214/n7/+JsdrOT/r6/fmbi5IMb9//7sMbuuyr81f0C8fy83Va9U7NldLHe91r5yU9Aa69Nn5GyT2RDmE+UITnVPIyD19+urr8IaYgz3N2x/9J5rSuPGh88FAhsrXP69evv/376UBtHp3Zr/2CWF2Bg55Yz1f+6F+vTHnb03uf3FWBnY5UwEbm65/SfcO1UGxXwi08T/LxfntvavPiqfP1+d+dWz79I+WeVhgs8XujnXOx7Jv97Sffbbp1eMpXkink2NQbKsKHr/fnv/m52VCchiYuf88+HbXwzTUR3x41JHcNTse2wSolw/3rznscmf0JNiyAfUz8ijn9K+IP7OBIeIDq3pwuzf33z5xyAsoKr0d9GT3/wqmhJn915/x6qobyfPw4RuBTO3ENvPX/9Azvn+jVWImxldAZojfr++8Sdx28VidTaGf+/3ZWk7u3yVu7PE5ceJk/9MrKVZWQSkuL/c/CkbbPh1/o0vWfKMnz9wKktzMPxXT6gQf94vWO7/+zVmqcOh4qz25cbL374cj858UHdR5SDgCA61uDJVRXCSYRI0C3fgm7ln/Y3vzmLXFnZuPqjM/fnOFe2GdmNx6ZbabeVVjac570uU1psKSLE5Mvx4kpPAIakvIguOvK+396xbefTJA+7lq1RCAx18W8KK+hpbBJ6/TWz3EcUIKjRHsMo6OSN4//7+Z2DjYmVkVU6eNQtFnWxI37IQVOfLGOvDOYzcqq6xNUAEE9DNnjEDw2pcjkAGv1+cv/pZxNVfnROPduoAnI74cnbqtOdunfU2vDR3Aw5H/H21rTTtcMDKHQny9CjXsdjx99XO8tBegb4dLS4imImIHo74/XhtfsIK9f4NeUaIsp2ujvj9aEmsUytLbrPSs4Nbn4GFmAW07KyVuGnrHhRHfL+2csPdGz8LQpcixDTablysVGdD10c7R/B5bP4xEO0s+jdqsIBB4QgAXJ9PGuTp2yYAAAAASUVORK5CYII=" width="44" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<img height="21" hspace="8" name="Object8" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADEAAAAVCAIAAABgw5FrAAAD0UlEQVR4nGP5//8/wyADLAPtgB+XJjYelZ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YHfT31fbStMOB6zckSA/AJUPFiv/vtpZHtor0LejxUUEMwHSAaC76ffjtfkJK9T7N+QZ8TIOhIMY0Nz0+9GSWKdWltxmpWcHtz4DCzELaNlZK3HT1Xkobvp+beWGuzd+FoQuRYhptN24WKnONmBu4vPY/GMQtDoHvE2HBQxGNwEA5O95ZCndrsQAAAAASUVORK5CYII=" width="49" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<img height="21" hspace="8" name="Object9" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADsAAAAVCAIAAAB34QGiAAAEHUlEQVR4nGP5//8/w5ACLAPtADzgx6WJjUclZR88tW4o1OeEiQ5mFzNz8/148fTZNz4eZFcS5eJP+wvS1/LrCL06e1+jPOVRRuKm72zMDBw65RtXhH+akdV8U8mI78l9qbz+bLmTCJV1M/IMGK9OL5v9Wpbn8X3Zgv4MbU5Ms/+8OjqjtGSb45rNCdLMDN+uINT3+l6+pB7T4rSn+szrf8pSTKS4mFXat6bdSZv342Zfw45r6VErLpSacYNlPu8Om/Qt+UydO8f1NpeqbWFL9RAqW44lTH1bvVKxZ3ex3PVa+8pNQRvCxcD2/v/19TsTNxfQ7v/fnz1m11X5t+YPSPzfy01I6rd41Ku8Pbz9wAtlU34mhGOIcjGnmrM22MQ//ziFORiRZJjYuZi+fPzxj4FPXJ3j1sH7jCEIlSLcv++susntL8bKwC5nInBzy+0f4WIc3169/f9vX0qD6PRuzX/skkJyxvo/90KN/HFnL7L6p5qzq40xHENCOv77dPtq1rRqW+UTF08e/vrl9qUPenExVm19lg21ZddVJV49+fjp+18klfUm7I/6frOzMoF9xvnnwzeg7M+Hm1u6z3779IqxNE/Es6kxSJYVyYZv79HVYwJUF/+41BEcNfsem4Qo148373ls8if0pBjygYz4/+XCrJ478TNrtMWZtVVAAhqvPFzbdE50e9XO8gImx3sTVs1/zseCpFKd7edbIbafv/6B3PL9G6sQNzPQPgEVTYmze6+/Y1XUt5PnYUKxnpkbQz0hF/9+feNP4raLxepsDP/e78vSdnb5KndniQf/x9Oz+o7pVNfYijC+P7/7tYarGjAP/f/369uP95eP/FKzkWd5eWjrN4cmNbYPp2dCVQKt41BxVvty4+VvX45HZz6ou6hyAJ3yn1k9oUL8eb9guf/v12hVARb1hFzMoRZXpqrIBmIyCZqFO/DN3LP+xnd75vqIynXM4qumA1Woexvy/DmuK/bj3hWdhk6jv0ezaxbsVfh5/a7DtCnmTGcKESp1KzcuD20JK+prbBF4/jax3UcUGKJMUjaODD+e5CRwSOqLyDL8/3p797qVR5884F6+SiU00MEXXT0hF7PKOjkjeP/+/mdg42Jl5DSZePf9RGy6gUBu7uJIBM8MQ2X2jBkYejhkjPUhLEZuVdfYGiCCSeliU4/Hxcjg94vzVz+LuPqrYylEBxLgdPGXs1OnPXfrrLfhpadziADYXfz31bbStMMBK3ckyA+6ahyLg/6+2lke2ivQt6PFRQRr2h9YgO7i34/X5iesUO/fkGfEy4hVx0ADFBf/frQk1qmVJbdZ6dnBrc/AQswCWnbWStyDyPEoLv5+beWGuzd+FoQuRYhptN24WKnORm934QYoLubz2Pxj0PdIBl1RQBAMPRcDAG8I0SmqOsZVAAAAAElFTkSuQmCC" width="59" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<img height="21" hspace="8" name="Object10" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD8AAAAVCAIAAAB+CqHYAAAEUklEQVR4nGP5//8/w5AFLAPtAOLBj0sTG49Kyj54at1QqM8JFhpCrmfm5vvx4umzb3w8cEcT5fovhwoSlnAbSLw7e1O+cnaxwuWZpSXbHNdsTpBm/n6q2Cpi03c2ZgYOnfKNK0IfliCpLDfj+XhiUv3qj5JCX+/+CJjQb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As6vG4Hhn8fnH+6mcRV391LKXyYAE4Xf/l7NRpz90662146ekcEgF21/99ta007XDAyh0J8oO6KYHFcX9f7SwP7RXo29HiIoKZUQYVQHf978dr8xNWqPdvyDPixVGfDiKA4vrfj5bEOrWy5DYrPTu49RlYiFlAy85aiXuQegTF9d+vrdxw98bPgtClCDGNthsXK9XZ6O0u4gCK6/k8Nv8YUj2tQV2kEARD2/UAOULvOzYtN04AAAAASUVORK5CYII=" width="63" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<strong><img height="21" hspace="8" name="Object11" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEkAAAAVCAIAAACFXVQHAAAE7klEQVR4nGP5//8/wzAFLAPtAKqAH5cmNh6VlH3w1LqhUJ8TJjo8/MbMzffjxdNn3/h4kP1DlN++HCpIWMJtIPHu7E35ytnFCpdnlpZsc1yzOUGa+fupYquITd/ZmBk4dMo3roh4WY7grp+hubF59UdJoa93fwRMKHoZql9wh4uTieHPx486M08V7itcCjez3Izn44lJ9XDFzVbc2Bzy59XRGXCrGb5dmV42+7Usz+N7vOps6jEdTnuqz7z+pyzFRIrfmMXdq7o8jAQ+bvEz6jnsXy6uq/JvzR+oATJRKy6UmkGd8v0tgvv9bKX//dB1E214/n7/+Jud5U7G+ou+xgIMb3dUTeVzFBFmRZh5KnuhYGcdkmKYzf9/ff3OxM0FceX/788es8Ot/vdyU/VKxZ7dxXLXa21zn7kIbj/wQtmUnwnhbKL8xqnuaQSk/n599VVYQ1bJWJNlLyNBTb/ub93+6D3XlMaND58LBDZWuOn4GQOFf99Zu0U6rI+Xkw3JTDGG+xtQFXMw/Pv26u3/f/tSGkSnd2v+Y5cUYmPklDPW/wmz+sedvTe5/cVYGdjlTIRebPGODLHmQnUBkfnt/5eLc1v7Vx+Vz5+vzo4swSKsIn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" width="73" /></strong></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><img height="19" hspace="8" name="Object1" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAATCAIAAAABJ4pRAAACCUlEQVR4nGP5//8/AwHw//ePvywcLIyE1AEBC2ElP64tWfI3KVUfn4UwNxE27s+rm5/UnYlwGVHG/f94+6GyFi8RYUKUcd8e3BRVs2UixiwijPv19BqDZhAbkaYRMu7v2xuv1W24iDWNkHGfb9+VV/UiJokQY9z3hzf4Ncygav692dcQFdG8R2PxxarblXn9W2+z2Lbt31mpz4nbuP/fH198wq+nygcK/N/Pr3/X8OaASjGJOOYkqLftfTq/cX9q56nHtU26FjOX3SzUN+DAbtyPexv6OifPvhayf3+mAgvDv/e3nqgacSPJPzp1/6+wc/GMdi8Rph/nWZiYecV4mHF6llnANHvCTE6XqCW3k2s02b7evSWl7oxII/+/3Dn/kts2xlYEKPb/6/1zzznVdMVZcRrHKiTNz/A3PF3Ia/bF4j7dR9fZNPWRVP98dPr+P3lvebDffj45ffevbIYCBwNO4yBOlPTJ0eidevRt08cPGk5IaeT/l7tnn3OqG0iAbfh29/QzdjV9CRTHYYtZRiHHXJva7rVHrRTtApDEfz4GOk7OQ54Twjlz749cCprjsCcUbpMM37sec2x2ByGF8/+vQMdxqBlIgt3z9d7px//enli+5UF1kAIi02BPd+yaCZmW77Tl2JEdLRyy71cIjCcUuPs3lkIBRzJmUcpaMwW7FF5ARPFJCgAAIg/CCBC4piIAAAAASUVORK5CYII=" width="26" /></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<img height="20" hspace="8" name="Object12" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAUCAIAAACMMcMmAAACZUlEQVR4nGP5//8/A40BC60toNyOP6+Ozigt2ea4ZnOCNPOn/QXpa/l1hF6dva9RNyPPgJuRCnb8//7sMbuuyr81f8BcVmnfmnYnbd6Pm30NW44lrXHlpYIdjJxyxvo/90Kdy8Cp5qwNov/9+ccpws0MV0b9+Pj7dPtq1rR6Ey68dvx+dWR6cc50jslnZttyQ8X+f7k8pyB37h027p+vf2nnzJiYpA0LbmTw/8uFWT134mfWqLMhBNHs+Pf+5My67u33Hx24+CoISevHA0VeVW/7Lu8Nlfj/cI6bnmexypXp9nyotvz7cHpW3zGd6hpbEWZkcXR/cCiH96xOedJvtLUVyYo3u9oXf7Tb4C4B0isXXGCbH962q8UumPPOnnUrjz55wL18lUqoB1dfROU6ZvFV04HG6FZuXB4vz4LNDiZOESFgYKFZ/O3m9nM/pArlOMA8Rm5lU+kfU7bf+BZio+oaWwNEUHUT776fiBl+xMX5zxd33zLwiPJCQ4CZT4KX4c2dFz8ZGLjxayTejn+/vgKNY2ZjhgY/IwsbUNvPr7/+AT1OJTuY2LjZGRi+/vwDLdn+//4JzHQ83GzEWECkHQwckmqiDAdffv4L9A2Q++fTs48MIgYS7MRZQZwdnOoeRpwrzj38zqDFBsoDt089ZTdwV+cirJN4OxiFXSvjBIOn73juFi7578GaCUeFYje6i2DJg8TY8fvx5glTdl67fuAWw7t39WmZBmqWySVx2tx8dj1b2nJz/F0WCP5++U29f2e/Iz+xVqDbwSrrW9rpC2TMR/cKj17a/ENpxBqLzw6aAHrYAQDcbtq3+2CC4QAAAABJRU5ErkJggg==" width="33" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<img height="20" hspace="8" name="Object13" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAAUCAIAAACxo6JAAAAFMElEQV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kUsttGWdZ/jMWNfMky9v6a7ctzhUkQMjGaFYwQY0j+Hrzz/QptH/3z+BFQ0PNxuRjsbqbihg5FQOrMxuVKvrOFK7TklHgmHb/bfQWoyRXVCUi+HOq8/AEoUVWKGd7U+K67ykU1Qe+fGhpdgcO8Uul+Yl01M0OHCZzcAhqSbKcPAlyABQSPz59Owjg4iBBJHFKoa7fz/ete2Ljb8mF9zxjAx/f/35zybv6ipZu+vww19O2qA8/efL++8MYqqirGA1XNJ6LvX75odI7fGae8WwavsF3yUbGCTYGPAATnUPI84V5x5+Z9BiAxXlt089ZTdwV+fCpwePu/+83DtlKY9LvxUod/z/fGHJwut83vXmvAxcRoVVNgva+/fnzHIXZnh7dMU5dscOT0lItmKWcEkPA5Un7/8zf/36h1nYIj6ZgK2Mwq6VcYLB03c8dwuX/PdgzYSjQrEb3UXwJi487mYV05U4FG9iKiUjyPrrw6vPQk5zD7eGgMpYZuXM9Vu/ZFV4Ok8U/v/qNV/2uuXxcqhpjFk2cef1RHTzfz/ePGHKzmvXD9xiePeuPi3TQM0yuSROm5vPrmdLW26Ov8sCwd8vv6n37+x35CfB2ajuZpGLWXw2BrtCZhH7ilXHK0gwGgyANVlppy+QMR9NgpFHL23+oTRSzYOBwd2uwg2GqrsBHRj1jtMDRiIAAAAASUVORK5CYII=" width="61" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<img height="20" hspace="8" name="Object14" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAAAUCAIAAACoKEzmAAAGQklEQVR4nOVXd1RTZxT/sl4WYCBEw7SAMR5RNFh7wCKKDMUjDiDQesqIq4WKLBHFarTiwFog1YIDxYEVUAEPBYSixcGp1FVHMSqIDINEIqRmr9eEoIWcKNHjaQ/2nvfHu9+74/e791sPDcMw+NAF/V8D+DdkuJNU8ev3pqyu9DlV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8dUmoHlzTo1CrOWDglD90wGBhrS45WKF1g/53kmq+ZUpKy4tLDobPVrniLJbfLymOyElmlGIJY9ymjIFKABuBB6FxBCxAEelOVroSo+nfxY3LT60uLItbQKNMJaZXhIYvi/CP6ah68HEovPHmE44w3VpKEhIGw+I5ar+azaslGtPfzMiZArDtyOp5lenMr8nZZ5N97N+GR1pNS3haH2CXhFfYp3m2Ls7YCHEBCqobBHo7yEAgbWkEEAT/4UawLLrWUsiM25PSEr9XNjqOTLP22mn35aC3GXjcEZz9gvOZiwFXOjSBgC6sqn+4gmB9WSqiSeSySSV7afjowvpWWWr3M0HFB7WwAhkvy5vPntR4Bg8zxmCNP7+NhtqLrUqZrnqtmSVqEcKRtIoGIDA2Ln5sc/nh9rWzj14l5FW9UdQQRmgQkNkx9PnuOMLb7RKwXhId2Q+/P0JdvJsOuF9klS2FUTM2oqO2+LMu1DB6xtCkcZ7fzq698jiHc6HdnsTASxpPJCYIwnPS56k64l7YprX4e1Zv67cP5sMBPWFN7A+OwJtdF2g+n0Zpttde2CUWKxCkT2ilg4NAEH2XxdpGZJ7tjMg3Ebz+FR2vVXEmdnWQ03z15BUtpdn76luvFf3ADx/zl4RM3ms59LVkQ6NRWXNXHkC8/g/luO2cW+lksn4C0s8POytMeIeud3c/CvshX0nGcC4xJRWiGLXBvpyyDD/mcXXJSeiHAfkQjmwqu+xjNXTKABXooX3rp+3xa1c4HfYUtkloWdVZ/mMMJWjIUmMQ1BKRpD2JX/Q8JxymfFf66DDt4OMB0ZZz1hb/NtaU3EMAUDbTDO3FfkXV7xtvD75kC7or5X/Bcm/AQSYhSGlvShAAAAAAElFTkSuQmCC" width="76" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<img height="20" hspace="8" name="Object15" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAAAUCAIAA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BezfZrS/69lVIjKOm60pBk/3Ga6GUKf9zU5sC/9qUWwTH175vPa3haPeEq9WixPSwVRwyzO8n7qi8sNnVYmGAsGT87a1LljhT0OIhOW1N6Xfsj/WPibfqIF1i636Knain7LleUFjX+lPjMzA4yI5P8JrnF/fZJiaBGHD0m+yknR8Fldkp+ySM/Lr8QNvf4MkkUyDiijMd96caYR95Bx53+yMpy9Mv/zt9WnwEJbzscbh52lt1zADtEp6Wo9MrndABWS+ML70T/5vExmEmfxBaxB+mmMF/AZzOQaLXRWJTAAAAAElFTkSuQmCC" width="92" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<img height="20" hspace="8" name="Object16" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAUCAIAAAD0og/CAAAHRElEQVR4nO1XeVRTRx+dLGSFgAnBsMVSieFrUFGwVSqgFqTYD6kCYj0HELEoEmWxKMWFLkCRYhCkRTSgR/Qg6kdp1SBWNGJpBSm2pQQXKCAS2RcJgZDlNY8gTTAL7T893znckz/y5t3f3Dv3zbyZh4YgCMxiZkD/2wb+nzAblgqy7qoT8R/xVl++stUapeirOMy+gHKyaKtDhnz96RoKUkWaDQsGNCpsxy60V1yWwVeKbl7qNTvOvf3MxoTle3lRq4JpqrRmw4KBwNOdF0sqEKorJI5igRoWy4FcNISkUnDIl7TZsLTA1D3GKzWeHUcX/LbueIbZVPurYUk7eCl7kq91YQiKQWGfxYclV/axxis2WXleEmnwbONqHx91xsEV3T/k7mXn4o7XnnIjqm4qhu5/tTs6rwFjTZZ3CeWLI7Ozd7mYItXKFb288IX+T/M6K9ab6tTF6uHPAFqMAUhUz43Znd+EIUp6xlnsE1nbWESEZplEwIn+eXvJ9a1znxd4+3MaKg+xMNrCggb5catCH8X9cDeSiQPSpqxNOUNy+AbOMSL/4AYrlMp4D+/jDJMQFg4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gYS0ca4LX0ySbtYOdQCaCpe1i5L02ENdaQe7R7S5ErSX+fClHrw35gZmM22TmaYkcBvYKWjtunTt66e5KSrcb1M0M45Twp1Kor5F/Vzm+9HzUPDQ3/nLkt5MhvjnH7PxhqW2HBdbdL9/z8XO52B/W3hiZwlguo4E4XPCA4f9kL4RAwd6LpXyZ/QTOseV5elodu3G0bXzNxspCJBkaBBYOqmlZQ342UYuu9lQswBvpUnoDNsUA4OKpQeZKLekcAztbcYm3Bg9qpE8HQzfB3EtBH+dz3WHTbZm26dt47tfMtYdcIgvUiz6RbpwOsbq7L/31JYtkvvudKAU2vOTzz3aX4C3Vto+ANDHzkelLTgXXyZhL+SViAsDQ2ceWZLzJvs096U0Bf1YU67Oo0H8uJVSBtOpPyixcnn2Z4zpq4bPUmBRd/3xG+jY4G4y3fnROY+hx2MTOjkp2nSP0tJIAwsndyYioPmabadG0o9Nco2vkwUDTPHZvg3XAAQo2MyFCU5aHhBowhKF4fh8zxz73+fG2QpaL18rEqcvC33uZ6167OsJTbWOQ310S7EnzeyaJA3T2kqJKiUDrMgV5UpedCEWVvGmvwpe1XjuWUCxr5j0F/f1JEpNOCFeEfhbAs3i+4+il7n59HsbWZvOeZmJFWlu1H1ZOyTl3DQNmGlTeGTW/VYYxIcs+4mrqb7ed5Zo60S8zMLM9crXdf18ArhlDmHgkXf0qY3owgrTrVVPNKuZGtb/wRX+Wf09N6objFF/0Ur0+ZHFAJqW1dOnR18g1AlzGAMF4UcboyYsYdqWP2Q/pvYDasv4E/ASAKZ5btyi+NAAAAAElFTkSuQmCC" width="100" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<img height="20" hspace="8" name="Object17" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAAAAUCAIAAADTDI4qAAAIRklEQVR4nO1YeVRTVx6+L/sCIRACYVU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WIUMIhkt5cSUZW02LF137onN/pv/9riUDxhID4IREJlutsTs+82DwEoRguDFT614liuTNGOsSqiEO9z6t63HzTNPssnyrbLubESq0CtjzzICEo9GW7CWj0/ubqIACGvBYjG1YH7vjzkN7YFW8+XlZfzKtAvNFoFX7BAfAkh9Ja8veTsew4QeNW+rKGgbkaKpVuzfzetVrwfANmL/yvNfJf8QcsaVBvjV2ffxa4+7Gyj3FzSD89kWxWmhB0YPDEjRNPttATOkA9Gcv/DR9kwranfxMpC9yj1RreP9vavutHsJUrgQnkas8Le3N9bFDvSIjdZl3YnZqDjhyRB4RE/E+Sz4MMfm8nwDgvypLjbz/0f5/hWKbCUtN06cKq57Vv4cdHfHBAWzFjoEfO7zG4T6A3VX8xvrxeHcyxO1F8XVP9xHQ/KDXRB8vUCwM9rdKYUG8zopu/KubDNV/XWiTfyKn/lNtazemDWZwk78Z1xoyAbOeW3JWyEzuTh5rdZss1UNF6Xrcf6Rx7siJF4FOpsr4bFHL+mjuB/q49SIsCYeUfGKSlkqNFl9fYrbDZH6V/nIftC6q6NzfoyewexsjckXisbSoKzKoP+23gjmXtx8QMyF+wHxCyBXUyvvstGgAAAAAElFTkSuQmCC" width="116" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<strong><img height="20" hspace="8" name="Object18" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAAAUCAIAAACMHQFjAAAKlklEQVR4nO1aeziUaR9+5nw0hhl2GGxosFE51cai1JDalYS0fZW0qiUiLZW2pnaxUpG2qI2OWukgbRuxHaR8nbbaTlKNJBkZhMzJnN5vxmgzmndrvj++77rK73Jdrvf33s/9u5/3ft7n4IWGIAgMxccR6P+3gKH438WQ2R9GyPk1O5K+K/M9enI+EwWUXVe2co50mxkL6yXTt/zoSdKAhsz+EAIS85pwI4crj8r7L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bqBo3klFl5MGZSkBJyUw/yqBoEzYxb02OKsnf98d+viVhy+v1E7C6Yepi7aac+DGHN1C9eTXjX93YCwDkzaoKfcMFkwetWhP9SJ9+fpi6EPIRxRDZn9E8R/b+9Oujm7S4gAAAABJRU5ErkJggg==" width="164" /></strong></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">n</span></span></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<img height="20" hspace="8" name="Object19" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAUCAIAAAD+/qGQAAACPklEQVR4nGP5//8/Aw0ACy0Mpdjcfx9OTKpf/VFS6OvdHwETmq24qWPu9/OddfdD10204fn7/eNvdmQpSsz9dX/r9kfvuaY0bnz4XCCwscKNgzrm/vn47Lu0T1Z5mODzhW7O9Y5nZ1hx4TP396sj04tzpnNMPjPbFhZi/79cnlOQO/cOG/fP17+0c2ZMTNLmZuYWZv/+5ss/BmEBVaW/i558/8/AxYjd3H/vT86s695+/9GBi6+CEML/Px4o8qp623d5b6jE/4dz3PQ8i1WuTLdXcDT8Ov/Glyx5xs8fOJWlORgROtDdy6Ec3rM65Um/0dZWJGPf7Gpf/NFug7sEM5AnF1xgmx/etqvFLsS+pXZbeVXjac77EqX1ptwMOM1l4hQRAgYEmmXfbm4/90OqUA4SL4zcyqbSP6Zsv/EtxEY2pG9ZCJagJC7efr64+5aBR5SXGcJl5pPgZXhz58VPBgZuXFqIMfffr69AI5jZmKHhx8jCBtT28+uvf0APUmAuExs3MM1//fkHWpL8//3zDwMDDzcbLkOJNJeBQ1JNlOHgy89/ga4Gcv98evaRQcRAgh2PFqLM5VT3MOJcce7hdwYtNlBSvn3qKbuBuzoXHi1Emcso7FoZJxg8fcdzt3DJfw/WTDgqFLvRXYQRjxY0c38/3jxhys5r1w/cYnj3rj4t00DNMrkkTpubz65nS1tujr/LAsHfL7+p9+/sd+THZyy6uayyvqWdvkDGfHQn8+ilzT+URozvsJlLNUArcwFt5dQPkTUnjQAAAABJRU5ErkJggg==" width="29" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<img height="20" hspace="8" name="Object20" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAUCAIAAABEXSnwAAAEAElEQVR4nGP5//8/w2ACLAPtAHQwMA56v95Lv+AOFycTw5+PH3VmXl3vJ8Q4oA5iU81Yf9HXWIDh7Y6qqXyOcNcMmIO4dfyMgdTvO2u3SIf18SJLDWQa+nJm8WX7jGQ2FEFMB/1+uq01r2XrSzaufx+evRVLXbe5TJudOBt+vzoyvThnOsfkM7NtuaFi/79cnlOQO/cOG/fP17+0c2ZMTNLmBsfQ32dbF/0O65JkRjUDzUH/Pxwocoi/WXTkcKY6BzBIJ4ZN+fiXGLf8e39yZl339vuPDlx8FYRk3scDRV5Vb/su7w2V+P9wjpueZ7HKlen2fIwMP68t3qYaO5sX3SBUB/2+O69g5u/Ek4lA1wABq0r+un4GRjQt/39/+/aHjYuTBUWCQzm8Z3XKk36jra1ISt/sal/80W6DuwQoHOSCC2zzw9t2tdiFCL/fP/uWZ4UaGwM6QHHQ32c7l1zktOhT5YALMaI7h+Hv4zm2+hvq7+/0E0ASZeIUEQJ6CE3tt5vbz/2QKpSDmMfIrWwq/WPK9hvfQmyEPCbNxXAMhoN+PDj5gIFVamdTfN+Z208ev2JQD6qe2BSqDDHv1+05pYtFi6rtZSSlFEVZvlxb1DCXs6AzVAZ3xvj54u5bBh5RXmg6YeaT4GV4c+fFT2A+w6UFNYS+vf/GwCpqmjKxrYuP6fuNaZ6GYb7cl8/X6wBT9f8///l5L9fa2ZkEivB+WZVoueGxYUYDwz+crgEmrF9fgXYzszFDg5mRhQ1o38+vv4CamIhxEBM7NzsDh4SqHB/IS5zqEblW+SGrtj2q0lFlZWDkUgttWecZPjPWNfPky1u6K/ctDlXkwIhRFPPYgOYxfP35B1pd/v/98w8DAw83Gy7XoDuITVJHgmHb/bd/oB5iFxTlYrjz6jMwn7Ey/P98tj8prvOSTlF55MeHlmJz7BS7XJqXTE/R4MBmMBhwSKqJMhx8CTIA5MU/n559ZBAxkMBXiqA6SN7VVbJ21+GHv5y0Qen/z5f33xnEVEVZwc7jktZzqd83P0Rqj9fcK4ZV2y/4LtnAIIGZT5AAp7qHEeeKcw+/M2ixgYqk26eeshu4q3MR6yAGLqPCKpsF7f37c2a5CzO8PbriHLtjhye07GKWcEkPA+Wy9/+Zv379wyxsEZ+MzzUgTwi7VsYJBk/f8dwtXPLfgzUTjgrFbnQXwRfPaDmEVTlz/dYvWRWezhOF/796zZe9bnm8HKoaZtnEndcT0c35/XjzhCk7r10/cIvh3bv6tEwDNcvkkjhtbj67ni1tuTn+LgsEf7/8pt6/s9+RH2+6w8iyzCL2FauOV+DTgw2wyvqWdvoCGfPRJBh59NLmH0oj2qDRBhohAACxm3KzKQxgwQAAAABJRU5ErkJggg==" width="48" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<img height="20" hspace="8" name="Object21" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAIAAABXimkEAAAFE0lEQVR4nGP5//8/w1AALAPtAGLB4HLov7d763JWMBuIPTzHFDet0UmYCS41qBz679W2tq2KfSfK1a9XWBRvy3aIlYC7dFA5lIlDWIz587e/DH+/fGQSFeZgQpIbVA5l4LcrcG0r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iqiTIcfAkyAOT1P5+efWQQMZDAV9qhOPT3413bvtj4a3LBXcvI8PfXn/9s8q6ukrW7Dj/85QQu2P58ef+dQUxVlBWshktaz6V+3/wQqT1ec68YVm2/4LtkA4MEGwMewKnuYcS54tzD7wxabKAi9fapp+wG7upceLSgOPTPy71TlvK49FuBkvT/zxeWLLzO511vzsvAZVRYZbOgvX9/zix3YYa3R1ecY3fs8JSE5AVmCZf0MFCuf/+f+evXP8zCFvHJ+FwJ8pywa2WcYPD0Hc/dwiX/PVgz4ahQ7EZ3EXzpBcWhrGK6EofiTUylZARZf3149VnIae7h1hBQWcesnLl+65esCk/nicL/X73my163PF4ONdkwyybuvJ6Ibv7vx5snTNl57fqBWwzv3tWnZRqoWSaXxGlz89n1bGnLzfF3WSD4++U39f6d/Y78eNM1imUscjGLz8ZgV8gsYl+x6ngFPrOwAWAVUtrpC2TMR5Ng5NFLm38ojWiDBlejBA8YMg4FAP734LmxeDFTAAAAAElFTkSuQmCC" width="56" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<img height="20" hspace="8" name="Object22" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAUCAIAAACyFKxoAAAF1ElEQVR4nGP5//8/w1AGLAPtAErB0PDAv7d763JWMBuIPTzHFDet0UmYCS41JDzw79W2tq2KfSfK1a9XWBRvy3aIlYD7YEh4gIlDWIz587e/DH+/fGQSFeZgQpIbEh5g4LcrcG0rzSmSu3bJa3KPALIUmgf+fTw9NTd/5lU2aaG/L5/91c+cNCnLhB/s499Pt7XmtWx9ycb178Ozt2Kp6zaXabMj6XyzLVk3+NHMF3v9+Il11+9XR6YX50znmHxmti03VOz/l8tzCnLn3mHj/vn6l3bOjIlJ2ty/rvXln01ZtyNB/Pk89+C+q4dqtdmwe+DbqWr/vAMRJ673mXP//3ysQMvap9zo7g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OUwOqB4AVngg7w7MP3/9B9P/98uYrA4esCAe7vKurZO2uww9/OYEL4D9f3n9nEFNVdM84fwZemn7ck+xcwdJ7YI63tiTIVEYuaT2X+n3zQ6T2eM29Yli1/YLvkg0MEmwYTkACnOoeRpwrzj38zqDFBqoSbp96ym7grs5FpAcYeE0S3PliV+5+mpwkx8Lw6/6mJdf4PetMeBm4jAqrbBa09+/PmeUuzPD26Ipz7I4dnjLCcgrCcM3v7vMxMLKqGBioQysyZgmX9DBQKfT+P/PXr3+YhS3ik/G5HuRpYdfKOMHg6Tueu4VL/nuwZsJRodiN7iL40h2KB5jEAuZtacwp87dfKS3w9/WTb6od2yf5iwJTIJNy5vqtX7IqPJ0nCv9/9Zove93yeDnimiHMsok7ryeii/5+vHnClJ3Xrh+4xfDuXX1apoGaZXJJnDY3n13PlrbcHH+XBYK/X35T79/Z78iPN9+gOYJZ2LZ0+fFSbO4Qsa9YdbwCt0lCIYf+4ytiUAGrrG9ppy+QMR9NgpFHL23+oTSiDRoajTk8YMh7AABh/TWTtSYOEwAAAABJRU5ErkJggg==" width="64" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<img height="20" hspace="8" name="Object23" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEcAAAAUCAIAAABQyLcRAAAF6ElEQVR4nGP5//8/w7ADLAPtAJqAoe2rb5enZDXfVDLie3JfKq8/W4cLKj6kffX5aPOkb8ln6tw5rre5VG0LWxciygiWGNK+YmLnYvry8cc/Bj5xdY5bB+//CBHlBEsMaV9xW7X1WTbUll1XlXj15OOn739hEqi++nGpIzhq9j02CVGuH2/e89jkT+hJMeRjYvj3fL6lVNIphEK+iH1PlzvyMPz7cHp6YdGsKyziPF+e/9bNnTYxVY+XEac5xIDfr45ML86ZzjH5zGxbbqjY/y+X5xTkzr3Dxv3z9S/tnBkT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c5/z+f7U+K67ykU1Qe+fGhpdgcO8Uul+Yl01M0OLDZBAYckmqiDAdffgbWRqDw+vPp2UcGEQMJdjwhge6r34/X5iesUO/fkGfECw9CYCnUskamLEMLYtKfD08/MghqS3AC0+O//4xMUHU/7+449FYuyEeJDZc5oLiS1nOp3zc/RGqP19wrhlXbL/gu2cAgwYbHhQyc6h5GnCvOPfzOoMUGqrpun3rKbuCuzoVHC4qvfj9aEuvUypLbrPTs4NZnYCFmAS07a0XGD8dX3XmeoqUAVP7v7aHpix6qpCw34f77dEFUh9K8yXbcwOx2bXbhtG/hc4r1OXCao8TNyCzhkh4GKgPf/2f++vUPs7BFfDI+L4FCQti1Mk4wePqO527hkv8erJlwVCh2o7sIvmSL4qvv11ZuuHvjZ0HoUoSYRtuNi5WyCgb/61wMlypIcgDLvJ+KSZsOVJlyM/z7Lsx5MMnCQkaE9ev7n9Je80/UB4Aqla+4zFGHRQqzbOLO64nojvn9ePOEKTuvXT9wi+Hdu/q0TAM1y+SSOG1uPrueLW25Of4uCwR/v/ym3r+z35Efb15E8RWfx+Yf2PuQZm37b7RhiDKJ+C645IupGrc5+AGrrG9pJ8i8+WgSjDx6afMPpRFt0JBu3eIEw9NXAHwihFvFazetAAAAAElFTkSuQmCC" width="71" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<img height="20" hspace="8" name="Object24" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAUCAIAAACVui2AAAAGF0lEQVR4nOWXezSUaRzHnzH3i5HL2JkhkZg2KsRGi1Qjl4615dpZ5RCVKNJmpWXaQtc1aZWtSButVq3VCstukrJWW20tJ8lIcstoYjKGuZh3Zxpi4p1j/9k9R89fc57f+3x/3887z+/3vA8KgiDwPg3U/23gvx4zE1hYn7HtQNNcG3JHK30HO9KSMB6akcADNQdOCDfdTXLDNa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AaUdfzZOEPlbl+Jji4xEqrGLkeGBRJR68DkEQkBYBExMDRTgk8hoI3Xbsn8ivzpEO3E6+t0YJ7TEVrloEWGOh6OQwB0lujE3UK51pSQWkrTzoawmpTCIDDHZD3aTSABu6xQzce/tsy9ov1/DYH/SxnkyPMA3mZYfNxcAkBjmZOATd7FAKKVyh93cUHelZUdUWoAixprygVOHp/+PbTU95SRsRS2OuUvEkmXzGM27pAmUHa38kH2hZUvBRGBzPH1ZWWWHGrTbzSQlHoUkHfENA3o7ypGgTBYBGTVZnjS//NM7vBOqHsgVdeEaBipk6tHHiGuw3+0v22IbAAoziSm+90Yq3cGAQ1S1SApT3XMy6SmOxlipKHBh7kfddIXsNaqgm7GtFfW8DpDltgLJeR8aozL7TNC8u3JUobYXQINjsTHM8fZN+IOuOmC3g1l+5jVxzyoCl7DpLK3OKv6NJ9EHJwUIrUtQ/epI5WkV/Xdc9GbZ/MX7pXB9Bkz64cr9HZcNVNT10dqACj9RdSq4Nt7eiG2mhxP3dAZ2X2rRRfxRknaS8+nlH+qLHqCXj1irU5wsrcYdPnGy3wxlZQEtP6ojENJ+JxRSahP1cl2BGBFFYHaRrxU4lgW7zHqnRdiNtLjizMDzZSLSvk7JDyxpB3fcIYIJKdj11L3R7lzTyvLekRMtjl7BWwDWcyMMooKPde0FSPyb8kdh/2kv/IUZ3/KPXG49TJorA6ch695fEFtfHqPP0bAwBBWrQ5p3rztIVm5OVB3XjvgP8BO6m17XVS6AsAAAAASUVORK5CYII=" width="80" /></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<strong><img height="20" hspace="8" name="Object25" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGcAAAAUCAIAAAAflbTBAAAHDklEQVR4nO1Ye1hTZRz+zq5nF4ZchmMgQQiYoE5FE4N5aQjog4aAWCmEI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TKp0mHFj5VJ03QlQhg8IDtGfX9avjbR7+0sC0TawoouLAiz03vQHWLTxUhkyXTmC/khYun0gzgmvPRu+NBiMapgsPg7fhKti1kkOGSmbla4ZJZmzsFcyYenRrJblndtGdpjuuPvhu3+uouDxvx00Zl7ouGP0zF4fT2WsxKPX0wcSkOs2fsl1UNIbD+YOrjAqgJAzImRB6siX1ho5Ov9VTCS2qvgHzbhpeDympU2AAAAAElFTkSuQmCC" width="103" /></strong></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">nlg
n</span></span></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>62746</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>2801417</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>133378058</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>2755147513</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<i>71870856404</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<i>797633893349</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<i>68654697441062</i></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><img height="20" hspace="8" name="Object2" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAUCAIAAADtKeFkAAABhElEQVR4nGP5//8/AwWAhRLNxOr/tL8gfS2/jtCrs/c16mbkGXAzkqafVdq3pt1Jm/fjZl/DlmNJa1x5SdPPqeasDaL//fnHKcLNTLL7IeDv0+2rWdPqTbjI0f//y4VZPXfiZ9aos6GIE6X/34fTs/qO6VTX2Iowo0kRo//7mfqIynXM4qumMzBw6FZuXB4vD9eGov/fm30NURHNezQWX6y6XZnXv/U2i23b/p2VZhPvvp+I3WwU/UwijjkJ6m17n85v3J/aeepxbZOuxcxlNwv1DThwuQ3N/T8enbr/V9i5eEa7lwjTj/MsTMy8Yjzofsat//+XO+dfctvG2IowATlf7597zqmmK85KtP6fj07f/yfvLQ927s8np+/+lc1QwOl2DP3/v9w9+5xT3UACbOO3u6efsavpS+CzHlX/z8dA6+U85DkhnDP3/sil4LceRf//r0DrOdQMJME2fr13+vG/tyeWb3lQHaTAhkM7in5G4ZB9v0JgPKHA3b8JFy10KT/wAABLU5A61zuQewAAAABJRU5ErkJggg==" width="21" /></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>1000</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>7745</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>60000</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>293938</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<i>1609968</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<i>5615692</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<i>56175382</i></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><img height="20" hspace="8" name="Object3" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAUCAIAAADtKeFkAAABj0lEQVR4nGP5//8/AwWAhRLNxOr/cqggYQm3gcS7szflK2eXm/ExkqafWdy9qsvDSODjFj+jnlPZq1x4SdPPqe5pBKT+fn31VVhDjI1k9zMw/P9ycW5r/+qj8vnz1dnJ0M/Io5/SviD+zgSHiA6DI/U6cDOI0f/n+fGT/0yspVlZBKS4v9z8/JdE+/9/u7awc/NBZe7Pd65oN7Qbc+HS/+/NvoaoiOY9GosvVt2uzOvfepvFtm3/zkr95FmzcJiNop9JxDEnQb1t79P5jftTO089rm3StZi57GahvgEHLrehuf/Ho1P3/wo7F89o9xJh+nGehYmZV4yHGY/fUPX//3Ln/Etu2xhbESYg5+v9c8851XTFWYnW//PR6fv/5L3lwc79+eT03b+yGQo43Y6h//+Xu2efc6obSIBt/Hb39DN2NX0JfNaj6v/5GGi9nIc8J4Rz5t4fuRT81qPo//8VaD2HmoEk2Mav904//vf2xPItD6qDFNhwaEfRzygcsu9XCIwnFLj7N+GihS7lBx4AAJqFl6x4At4+AAAAAElFTkSuQmCC" width="21" /></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>100</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>391</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>1532</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>4420</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<i>13736</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<i>31593</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">146677</span></span></strong></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><img height="20" hspace="8" name="Object4" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAUCAIAAADtKeFkAAABcUlEQVR4nGP5//8/AwWAhRLNQ0T//89n29wiz3nEKd7Zuetv0Z4lgWJMpOhn5JIQZ2EWt8nqzFa94n/n418GXPp/XOoIjpp9j01ClOvHm/c8NvkTelIM+Zh+Pjj7yzrSQuj3rfMfpO3FWXG6//frG38St10sVmdj+Pd+X5a2s8tXuTtL3L7duMlhJM/x/+vdK0z68Ry4/c+hFlemqsgGYjIJmoU78M3cs/7Gd7v/Zz4rhQsz/7xz+sFPrg/f/jGw4XA/q6yTM4L37+9/BjYuVkYuk+mnrUACBp1XzqKFDe7w+/3i/NXPIq7+6pw4leDT/+Xs1GnP3TrrbXjxaceh/++rbaVphwNW7kiQJxDBWKT/vtpZHtor0LejxUWECVMav/7fj9fmJ6xQ79+QZ8TLSEgzuv7fj5bEOrWy5DYrPTu49RlYiFlAy85aiRunUSj6v19bueHujZ8FoUsRYhptNy5WqrMRpZ/PY/MPEkuTgc7/AKUhh5codundAAAAAElFTkSuQmCC" width="21" /></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>19</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>25</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>31</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>36</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<i>41</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<i>44</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">51</span></span></strong></div>
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="65">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">n!</span></span></strong></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>9</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="66">
<div align="center">
<i>11</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>12</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="103">
<div align="center">
<i>13</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="125">
<div align="center">
<i>15</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="82">
<div align="center">
<i>16</i></div>
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33">
<div align="center">
<strong><span style="font-style: normal;"><span style="font-weight: normal;">17</span></span></strong></div>
</td>
</tr>
</tbody></table>
<div style="line-height: 100%; margin-bottom: 0in;">
<br />
</div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br />
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-2751916286370352672017-03-16T05:56:00.000-07:002017-03-16T05:56:34.152-07:00Chapter 1 Exercise 1.2, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<b>1.2-1 Give an example of an application that requires algorithmic content at the application level, and discuss the function of the algorithms involved.</b><br />
<b><br /></b>
<b>Solution:</b><br />
<style type="text/css">p { margin-bottom: 0.1in; line-height: 120%; }</style>
<br />
<div style="line-height: 100%; margin-bottom: 0in;">
Maps are one of the
application which requires algorithmic content. One of the basic and
widely used algorithm is the shortest path finder between 2 points.</div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<style type="text/css">p { margin-bottom: 0.1in; line-height: 120%; }</style>
</div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>1.2-2
Suppose we
are comparing implementations of insertion sort and merge sort on
the
same machine. For inputs of size n, insertion sort runs in </b><b><b>8n</b></b><b><sup><b>2
</b></sup></b><b>steps, while merge
sort runs in 64n.lg(n)
steps. For which values of n does insertion sort beat merge
sort?</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Solution:</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>
<style type="text/css">p { margin-bottom: 0.1in; line-height: 120%; }</style>
</b><b></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-weight: normal;">Solving the simple
equation:
</span></b></div>
<b><span style="font-weight: normal;">
</span></b>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><br /></b></div>
<b>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-weight: normal;">8n</span></b><b><sup><span style="font-weight: normal;">2
</span></sup></b><b><span style="font-weight: normal;"><64n.lg(n)</span></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-weight: normal;">n<8.lg(n)
(dividing both sides by 8n)</span></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-weight: normal;">n/8<lg(n)
(dividing both sides by 8)</span></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-weight: normal;">2</span></b><b><sup><span style="font-weight: normal;">n/8</span></sup></b><b><span style="font-weight: normal;"><n</span></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><span style="font-weight: normal;">2</span></b><b><sup><span style="font-weight: normal;">n/8</span></sup></b><b><span style="font-weight: normal;">-n<0</span></b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<span style="color: #534741;"><span style="background: #ffffff;"><b><span style="color: black;"><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;">2≤n≤43</span></span></span></span></b></span></span></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
</b><br />
<div style="line-height: 100%; margin-bottom: 0in;">
Insertion sort is
faster for range [2 to 43].</div>
<b>
</b>
<div style="line-height: 100%; margin-bottom: 0in;">
<b><br /></b></div>
<b>
</b>
<style type="text/css">p { margin-bottom: 0.1in; line-height: 120%; }</style>
<br />
<div style="line-height: 100%; margin-bottom: 0in;">
<b>1.2-3
What is
the smallest value of n such that an algorithm whose running time is
100n<b><sup>2</sup></b> runs faster than an algorithm whose
running time is 2<b><sup>n</sup></b> on the same machine?</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<b>Solution:</b></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0in;">
<span style="font-weight: normal;">100n</span><b><sup><span style="font-weight: normal;">2</span></sup></b><b><span style="font-weight: normal;"><
2</span></b><b><sup><span style="font-weight: normal;">n</span></sup></b></div>
<b><strong><br /></strong></b>
<table cellpadding="4" cellspacing="0" style="width: 100%px;"><tbody>
<tr valign="top"><td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="33%"><b><strong>n</strong></b></td><td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0.04in;" width="33%">
<b><strong>100n</strong><strong><sup>2</sup></strong></b><br />
</td>
<td style="border: 1px solid #000000; padding: 0.04in;" width="33%">
<b><strong>2</strong><strong><sup>n</sup></strong></b><br />
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">1</span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">100</span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">2</span></strong><br />
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">5</span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<a href="https://www.blogger.com/null" name="cwos"></a>2500<br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">32</span></strong><br />
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">10</span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<a href="https://www.blogger.com/null" name="cwos7"></a>10000<br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">1024</span></strong><br />
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">14</span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<a href="https://www.blogger.com/null" name="cwos8"></a>19600<br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">16384</span></strong><br />
</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">15</span></strong><br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0in; padding-top: 0in;" width="33%">
<a href="https://www.blogger.com/null" name="cwos9"></a>22500<br />
</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.04in; padding-left: 0.04in; padding-right: 0.04in; padding-top: 0in;" width="33%">
<strong><span style="font-weight: normal;">32768</span></strong><br />
</td>
</tr>
</tbody></table>
<div style="line-height: 100%; margin-bottom: 0in;">
<br />
</div>
<div style="line-height: 100%; margin-bottom: 0in;">
<br />
</div>
<div style="line-height: 100%; margin-bottom: 0in;">
For n>14 the
<span style="font-weight: normal;">100n</span><strong><sup><span style="font-weight: normal;">2
</span></sup></strong><strong><span style="font-weight: normal;">runs
faster than </span></strong><strong><span style="font-weight: normal;">2</span></strong><strong><sup><span style="font-weight: normal;">n.</span></sup></strong></div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com2tag:blogger.com,1999:blog-619838397038898011.post-19739664818256105692017-03-14T10:14:00.000-07:002017-03-14T10:14:08.404-07:00Chapter 1 Exercise 1.1, Introduction to Algorithms, 3rd Edition Thomas H. Cormen<div dir="ltr" style="text-align: left;" trbidi="on">
<b>1.1-1 Give a real-world example that requires sorting or a real-world example that requires computing a convex hull.</b><br />
<br />
<b>Solution: </b>The contact book in our phones needs to be sorted alphabetically so that we can find person phone number easily. Some other examples are flights, movie tickets they are all sorted by time. Even our daily schedules are sorted by time.<br />
<br />
Convex hull can be defined as a step of points, a line connecting the points in a convex polygonic way, so that all the points are inside it.<br />
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<img alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQIAAADOCAYAAADVEgwrAAAABHNCSVQICAgIfAhkiAAAIABJREFUeF7tXQncVVP3XghfXwMhpUGjqIQkoVSkDCUyJSEyRyg+IiRTGf6ZklCGJFMfTUhIKZRUlAakQX0RoUJE7P/z7OvW2/ueO5x7z7DPuXv9flfeM+xhnbPX2XvttZ5nOwURK1YDVgMFrYHtC7r3tvNWA1YDWgPWENgXwWrAasAaAvsOWA1YDdgZgX0HrAasBqABuzSwr4HVgNWAlLI6iJ8G/vzzT/nmm2/kf//7n3z//ffy3Xffybfffqv/f+PGjbJ+/Xrd6VKlSkm5cuVk5513lkqVKkm1atVkr732kr333lvq1KkjO+64Y/yUY3vkqIHt7Paho16MPvj333/LihUr5Msvv5QlS5bI119/LStXrtTH+Fu7dq3sueeeUrVqValYsaL+/8qVK+v///e//y277LKL7t/mzZvl559/lk2bNsmaNWtk1apV2oCwPP5oGBo0aCD169eXQw45RJo2bSrVq1c3Wje2cblpwBqC3PQWyF3r1q2TBQsWyBdffLHN76uvvtIDe5999pG6devqLzgHaI0aNfSPX/UddtghrzZyVrFs2TJZuHChLFq0SD7++GOZNWuW/PHHH9ogtGzZUlq1aiUHH3ywnllYibYGrCEw4Pn99ddfwsH9ySefyLx58/Tv008/lQ0bNkjDhg2lXr162/xoADidD0M4c6BBeO+992Tq1Kl6VnLYYYfJUUcdJccff7zsv//+YTTL1pmnBqwhyFOBbm/ndJxf+Q8++EDmzp2rBzy/uPyKH3TQQXLAAQfo34EHHqi/9KYLlxbTp0+Xt956S9544w35/fff5bjjjtO/tm3b6qWIFfM1YA2Bz8+IDroZM2bIzJkz5f3339eDv2bNmnLEEUdI48aN9YDnVzQuA2b58uXy+uuvy4QJE3S/jz76aDnllFOkQ4cOUr58eZ+1bYvPVQPWEOSqOYf7mLYxf/58/YVMDv6ffvpJT52bNWsmzZs31+vrMmXKONwdv0Nc2tAgvPLKKzJ58mTd/zPPPFNOPvnkgtFBVJ6qNQR5Pil62t9++209NX7nnXf0NlyLFi22DH6u762I3rakURg1apRMmzZNTjjhBOnatatePuTr2LT6zV8D1hC41OEvv/wi7777rh74NABcIx9zzDFbfjQEVtJr4Mcff5SXXnpJnnvuOe0kPffcc+X888+XfffdN/2N9qxvGrCGIINquWdPL/mbb76pBz6n/vzi80vGH/fYreSuARqCYcOGybPPPquDmC688EI57bTTpHTp0rkXau90rQFrCBxUxgAbrmnHjBkj48eP1x799u3b64F/+OGH231zB53le4hbqFw6PPXUU9rHcs4550iPHj10rIQV/zVgDcE/Ov7tt9/0oB89erRe6zNQ5qSTTpKOHTtGYhvP/1cluBrod3n00Udl+PDh+jlcccUVejty++1taoxfT6GgDQG//JMmTZLnn39eT/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g9Oc7kdxD3h+fPnawyEdu3ayXHHHacp3K2k1wCJOtevXw+YtXWhT6sXLlwoU6ZM0YN/2rRpOnO1devW0qZNGwFsfuyCftI/mfzOFpwhKKouEE3IpEmTNF4ivyIEkaBB4BeOGWV2/Vjy5QrLEADhWebMmaN/jCzlFx9Tfj3g+eMz499WctNAQRuCoirj1BIcdDJx4kT9hZk1a5Z2KhEshUaBoc377ruvgHchN03H5K4gDAGDehjKC55IPfD5L5d3oIuTgw8+WP8IYAPfT0y0Gn43rCFI8QyIsrxo0SKdXcYf007BWKuNASMa9wfOOPfV+TfDTomyVAjilSFgeDh3HBi/zx/jE5J/g+Vqm0HPgR/X0F5T3hlrCFw8CX6VaBzolOKPcfd8ecFgo9enjEvnj1uVVatW1V+satWq6X/5IwpT1CUbQ0DwztWrV+sfdcN/QfCh/595CkuWLNEh4tySBAu0/pcGNfk367ASrAasIfBA34xK4wu+dOlS/UN4qn7xOcXlIACjkwZlJWx78lehQgX9/+XKldNOLaZc80tIvwQ98dybJ+Yd2J/0NZxxJP9mk+mxT+548Fqvliw0dhzIlA0bNghnRvx60znIX8+ePfWuwaWXXqqn60nHIc+tWbNGD3aep7+FPxpEGkn+S2csv+wc8DxmxRwNWEMQ0LPg9hsDcrhrQaPAH/+fX0YONMK6M0SaA4vXchByQHKw8Roam6KDlPckt/SSAzbZlXSGgYYlCarJ+iksm3VQip5PlkNDRAPFL3XyV/Rv/j8NGwOMONit0y6gl8rDaqwh8FCZphRV3DAUbVfS4PAYBy+FM5C45deb8iyi0g5rCKLypGw7rQZ81EDk8Ah81IUt2mqgYDVgDUHBPnrbcauBrRqwhsC+DVYDVgNmoxjb52M1YDUQjAbsjCAYPdtarAaM1oA1BEY/Hts4q4FgNGANQTB6trVYDRitgf8HJ9jLiwPSiUcAAAAASUVORK5CYII=" /> </div>
<div style="text-align: left;">
In image processing application Convex hull is used.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>1.1-2 Other than speed, what other measures of efficiency might one use in a real-world setting?</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Solution:</b> </div>
<ol style="text-align: left;">
<li>Computer memory </li>
<li>Network usage </li>
</ol>
<b>1.1-3 Select a data structure that you have seen previously, and discuss its strengths and imitations.</b><br />
<br />
<b>Solution:</b><br />
<br />
Array Lists<br />
<br />
Advantages:<br />
<ol style="text-align: left;">
<li>Access element in constant time.</li>
<li>Element can be inserted in any place.</li>
</ol>
Disadvantages:<br />
<ol style="text-align: left;">
<li>Random access takes n time.</li>
<li>Extra memory is utilized in making of index</li>
</ol>
<b>1.1-4 How are the shortest-path and traveling-salesman problems given above similar? How are they different?</b><br />
<br />
<b>Solution:</b><br />
<br />
Similar: Both are graph algorithms and find path.<br />
Difference: The shortest path algorithm needs 2 points, where as salesman algorithms needs a path between more points that returns to first point.<br />
<br />
<br />
<b>1.1-5 Come up with a real-world problem in which only the best solution will do. Then come up with one in which a solution that is “approximately” the best is good enough.</b><br />
<b><br /></b>
<b>Solution:</b><br />
<br />
Sorting is a algorithm in real world in which only best solution will do.<br />
Finding the shortest path between two places as couple of meters wont matter a lot.<br />
<br /></div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com6tag:blogger.com,1999:blog-619838397038898011.post-21011020394162070712017-03-13T04:23:00.001-07:002017-03-13T04:23:19.368-07:00Chapter 33 Exercise 13, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.13 (Day of week) Write a program that displays the day of the week for a given day, month, and year, as shown in Figure 33.36. The program lets the user select a day, month, and year, and click the Get Day of Week button to display the day of week. The Time field displays Future if it is a future day or Past otherwise. Use the Zeller’s congruence to find the day of the week (See Programming Exercise 3.21).<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.text.SimpleDateFormat</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.SessionScoped</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Date</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@SessionScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise13</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> day <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> month<span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> year<span style="color: #333333;">=</span><span style="color: #0000dd; font-weight: bold;">2017</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> String dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> String time<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getDay</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> day<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setDay</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> data<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">day</span> <span style="color: #333333;">=</span> data<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getMonth</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> month<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setMonth</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> data<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">month</span> <span style="color: #333333;">=</span> data<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getYear</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> year<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setYear</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> data<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">year</span> <span style="color: #333333;">=</span> data<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getSolution</span><span style="color: #333333;">()</span>
<span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"YES"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getdayOfWeek</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>month <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)||(</span>month <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">))</span>
<span style="color: #333333;">{</span>
month <span style="color: #333333;">+=</span> <span style="color: #0000dd; font-weight: bold;">12</span><span style="color: #333333;">;</span>
year<span style="color: #333333;">--;</span>
<span style="color: #333333;">}</span>
<span style="color: #333399; font-weight: bold;">int</span> yearOfCentury <span style="color: #333333;">=</span> year <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> century <span style="color: #333333;">=</span> year <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">100</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> cday <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>day <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">26</span> <span style="color: #333333;">*</span> <span style="color: #333333;">(</span>month <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">))</span> <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">10</span> <span style="color: #333333;">+</span> yearOfCentury <span style="color: #333333;">+</span> yearOfCentury <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">4</span> <span style="color: #333333;">+</span> century <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">4</span> <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">5</span> <span style="color: #333333;">*</span> century<span style="color: #333333;">)</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">switch</span><span style="color: #333333;">(</span>cday<span style="color: #333333;">)</span>
<span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Saturday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Sunday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Monday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Tuesday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Wednesday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Thursday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">:</span> dayOfWeek<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Friday"</span><span style="color: #333333;">;</span> <span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> dayOfWeek<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">gettime</span><span style="color: #333333;">()</span>
<span style="color: #333333;">{</span>
Date now <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Date<span style="color: #333333;">();</span>
SimpleDateFormat dateFormat<span style="color: #333333;">=</span><span style="color: #008800; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"yyyyMMdd"</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
Date date <span style="color: #333333;">=</span> dateFormat<span style="color: #333333;">.</span><span style="color: #0000cc;">parse</span><span style="color: #333333;">(</span>String<span style="color: #333333;">.</span><span style="color: #0000cc;">valueOf</span><span style="color: #333333;">(</span>year<span style="color: #333333;">)+</span>String<span style="color: #333333;">.</span><span style="color: #0000cc;">valueOf</span><span style="color: #333333;">(</span>month<span style="color: #333333;">)+</span>String<span style="color: #333333;">.</span><span style="color: #0000cc;">valueOf</span><span style="color: #333333;">(</span>day<span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span> now<span style="color: #333333;">.</span><span style="color: #0000cc;">compareTo</span><span style="color: #333333;">(</span> date<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">0</span> <span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
time<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Future"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">else</span>
<span style="color: #333333;">{</span>
time<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"Past"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span><span style="color: #008800; font-weight: bold;">catch</span><span style="color: #333333;">(</span>Exception e<span style="color: #333333;">)</span>
<span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> time<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setdayOfWeek</span><span style="color: #333333;">()</span>
<span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version = "1.0" encoding = "UTF-8"?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" </span>
<span style="color: #557799;">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns =</span> <span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:f =</span> <span style="background-color: #fff0f0;">"http://java.sun.com/jsf/core"</span>
<span style="color: #0000cc;">xmlns:h =</span> <span style="background-color: #fff0f0;">"http://java.sun.com/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><head></span>
<span style="color: #007700;"><title></span>Excercise 13<span style="color: #007700;"></title></span>
<span style="color: #007700;"></head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h2></span>Day Of Week Calculator<span style="color: #007700;"></h2></span>
<span style="color: #007700;"><hr</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:form></span>
Day
<span style="color: #007700;"><h:selectOneMenu</span> <span style="color: #0000cc;">value =</span> <span style="background-color: #fff0f0;">"#{exercise13.day}"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'1'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'1'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'2'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'2'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'3'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'3'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'4'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'4'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'5'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'5'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'6'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'6'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'7'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'7'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'8'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'8'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'9'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'9'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'10'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'10'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'11'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'11'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'12'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'12'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'13'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'13'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'14'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'14'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'15'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'15'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'16'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'16'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'17'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'17'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'18'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'18'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'19'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'19'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'20'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'20'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'21'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'21'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'22'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'22'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'23'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'23'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'24'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'24'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'25'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'25'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'26'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'26'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'27'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'27'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'28'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'28'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'29'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'29'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'30'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'30'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'31'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'31'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></h:selectOneMenu></span>
Month
<span style="color: #007700;"><h:selectOneMenu</span> <span style="color: #0000cc;">value =</span> <span style="background-color: #fff0f0;">"#{exercise13.month}"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'1'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'January'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'2'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'February'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'3'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'March'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'4'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'April'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'5'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'May'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'6'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'June'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'7'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'July'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'8'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'August'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'9'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'September'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'10'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'October'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'11'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'November'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue =</span> <span style="background-color: #fff0f0;">'12'</span> <span style="color: #0000cc;">itemLabel =</span> <span style="background-color: #fff0f0;">'December'</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></h:selectOneMenu></span>
Year
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise13.year}"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Get Day of Week"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><p></span>
Day of the Week <span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise13.dayOfWeek}"</span><span style="color: #007700;">/></span>
Time <span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise13.time}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></p></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-84564857497441349452017-03-11T04:49:00.001-08:002017-03-13T02:49:34.719-07:00Chapter 33 Exercise 12, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.12(Game: the 24-point card game) Rewrite Exercise 20.17 using JSF, as shown in Figure 33.35. The program lets the user enter four card values and finds a solution upon clicking the Find a Solution button.<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.ArrayList</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Arrays</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Stack</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.SessionScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@SessionScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise12</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">[]</span> numbers <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">];</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise12</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">;</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">;</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getSolution</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">sort</span><span style="color: #333333;">(</span>numbers<span style="color: #333333;">);</span>
String NumbersAsString <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
NumbersAsString <span style="color: #333333;">+=</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">char</span><span style="color: #333333;">)(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)(</span>numbers<span style="color: #333333;">[</span>i<span style="color: #333333;">]);</span>
<span style="color: #333333;">}</span>
String solution <span style="color: #333333;">=</span> displayPermutation<span style="color: #333333;">(</span>NumbersAsString<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>solution <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"No solution"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> solution <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" is 24"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber0</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> newNumner<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> newNumner<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber1</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> newNumner<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> newNumner<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber2</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> newNumner<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> newNumner<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber3</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> newNumner<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> newNumner<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber0</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber1</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber2</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber3</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> numbers<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">displayPermutation</span><span style="color: #333333;">(</span>String s<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0066bb; font-weight: bold;">displayPermutation</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">,</span> s<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">displayPermutation</span><span style="color: #333333;">(</span>String s1<span style="color: #333333;">,</span> String s2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>s2<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> checkValue<span style="color: #333333;">(</span>s1 <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>result <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">=</span> checkValue<span style="color: #333333;">(</span>s1 <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>result <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
String newS2 <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> j <span style="color: #333333;"><</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">();</span> j<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>j <span style="color: #333333;">!=</span> i<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
newS2 <span style="color: #333333;">+=</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>j<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
String result <span style="color: #333333;">=</span> displayPermutation<span style="color: #333333;">(</span>s1 <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">),</span> newS2<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>result <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">checkValue</span><span style="color: #333333;">(</span>String value<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">*</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">*</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> op1 <span style="color: #333333;">=</span> i <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> op2 <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>i <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">)</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> op3 <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>i <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">16</span><span style="color: #333333;">)</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
String tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"(("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"))"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"(("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"))"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">char</span> <span style="color: #0066bb; font-weight: bold;">getValur</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> intValue<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">switch</span> <span style="color: #333333;">(</span>intValue<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'+'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'-'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'*'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">evaluateExpression</span><span style="color: #333333;">(</span>String expression<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> result <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">=</span> evaluateExpression<span style="color: #333333;">(</span>expression<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>Exception ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">evaluateExpression</span><span style="color: #333333;">(</span>String expression<span style="color: #333333;">,</span> ArrayList<span style="color: #333333;"><</span>Integer<span style="color: #333333;">></span> verifyNumbers<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>expression<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Create operandStack to store operands</span>
Stack<span style="color: #333333;"><</span>Double<span style="color: #333333;">></span> operandStack <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Stack<span style="color: #333333;"><</span>Double<span style="color: #333333;">>();</span>
<span style="color: #888888;">// Create operatorStack to store operators</span>
Stack<span style="color: #333333;"><</span>Character<span style="color: #333333;">></span> operatorStack <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Stack<span style="color: #333333;"><</span>Character<span style="color: #333333;">>();</span>
<span style="color: #888888;">// Insert blanks around (, ), +, -, /, and *</span>
expression <span style="color: #333333;">=</span> insertBlanks<span style="color: #333333;">(</span>expression<span style="color: #333333;">);</span>
<span style="color: #888888;">// Extract operands and operators</span>
String<span style="color: #333333;">[]</span> tokens <span style="color: #333333;">=</span> expression<span style="color: #333333;">.</span><span style="color: #0000cc;">split</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">);</span>
<span style="color: #888888;">// Phase 1: Scan tokens</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span>String token <span style="color: #333333;">:</span> tokens<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #888888;">// Blank space</span>
<span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">continue</span><span style="color: #333333;">;</span> <span style="color: #888888;">// Back to the while loop to extract the next token</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span> <span style="color: #333333;">||</span> token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Process all +, -, *, / in the top of the operator stack</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">()</span>
<span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span>
<span style="color: #333333;">||</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span>
<span style="color: #333333;">||</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span> <span style="color: #333333;">||</span> operatorStack
<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Push the + or - operator into the operator stack</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span> <span style="color: #333333;">||</span> token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Process all *, / in the top of the operator stack</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">()</span>
<span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span> <span style="color: #333333;">||</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Push the * or / operator into the operator stack</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">().</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'('</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span><span style="color: #0044dd;">'('</span><span style="color: #333333;">);</span> <span style="color: #888888;">// Push '(' to stack</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">().</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">')'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Process all the operators in the stack until seeing '('</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">!=</span> <span style="color: #0044dd;">'('</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span> <span style="color: #888888;">// Pop the '(' symbol from the stack</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span> <span style="color: #888888;">// An operand scanned</span>
<span style="color: #888888;">// Push an operand to the stack</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Double<span style="color: #333333;">(</span>token<span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>verifyNumbers <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
verifyNumbers<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">(</span>token<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>NumberFormatException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Phase 2: process all the remaining operators in the stack</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Return the result</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">/**</span>
<span style="color: #888888;"> * Process one operator: Take an operator from operatorStack and apply it on</span>
<span style="color: #888888;"> * the operands in the operandStack</span>
<span style="color: #888888;"> */</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">processAnOperator</span><span style="color: #333333;">(</span>Stack<span style="color: #333333;"><</span>Double<span style="color: #333333;">></span> operandStack<span style="color: #333333;">,</span>
Stack<span style="color: #333333;"><</span>Character<span style="color: #333333;">></span> operatorStack<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">char</span> op <span style="color: #333333;">=</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">double</span> op1 <span style="color: #333333;">=</span> operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">double</span> op2 <span style="color: #333333;">=</span> operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">+</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">-</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">*</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">/</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> String <span style="color: #0066bb; font-weight: bold;">insertBlanks</span><span style="color: #333333;">(</span>String s<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'('</span> <span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">')'</span> <span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span>
<span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span> <span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span>
<span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">+=</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise12<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body><h:form><center><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
Enter four card values and click the button to determine<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
whether the four values has a 24-point solution<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><table><tr></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"50"</span><span style="color: #007700;">><center><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise12.number0}"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"50"</span><span style="color: #007700;">><center><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise12.number1}"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"50"</span><span style="color: #007700;">><center><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise12.number2}"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"50"</span><span style="color: #007700;">><center><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise12.number3}"</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"></tr></table></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/><p><font</span> <span style="color: #0000cc;">color =</span> <span style="background-color: #fff0f0;">"#FF0000"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise12.solution}"</span><span style="color: #007700;">/></font></p><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Refresh"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></h:form></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-66306742258815937282017-03-11T04:46:00.000-08:002017-03-13T02:48:23.609-07:00Chapter 33 Exercise 11, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.11 (Game: the 24-point card game) Rewrite Exercise 20.13 using JSF, as shown in Figure 33.34. Upon clicking the Refresh button, the program displays four random cards and displays an expression if a 24-point solution exists. Otherwise,it displays No solution .<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.ArrayList</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Collections</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Stack</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.SessionScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@SessionScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise11</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">[]</span> deck <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">52</span><span style="color: #333333;">];</span>
String solution <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise11</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
changeCards<span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">changeCards</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> deck<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
deck<span style="color: #333333;">[</span>i<span style="color: #333333;">]</span> <span style="color: #333333;">=</span> i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> deck<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> index <span style="color: #333333;">=</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span> <span style="color: #333333;">(</span>Math<span style="color: #333333;">.</span><span style="color: #0000cc;">random</span><span style="color: #333333;">()</span> <span style="color: #333333;">*</span> deck<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">int</span> temp <span style="color: #333333;">=</span> deck<span style="color: #333333;">[</span>i<span style="color: #333333;">];</span>
deck<span style="color: #333333;">[</span>i<span style="color: #333333;">]</span> <span style="color: #333333;">=</span> deck<span style="color: #333333;">[</span>index<span style="color: #333333;">];</span>
deck<span style="color: #333333;">[</span>index<span style="color: #333333;">]</span> <span style="color: #333333;">=</span> temp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
ArrayList<span style="color: #333333;"><</span>Integer<span style="color: #333333;">></span> numbers <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>deck<span style="color: #333333;">[</span>i<span style="color: #333333;">]</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">13</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">13</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>deck<span style="color: #333333;">[</span>i<span style="color: #333333;">]</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">13</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
Collections<span style="color: #333333;">.</span><span style="color: #0000cc;">sort</span><span style="color: #333333;">(</span>numbers<span style="color: #333333;">);</span>
String NumbersAsString <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">size</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
NumbersAsString <span style="color: #333333;">+=</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">char</span><span style="color: #333333;">)(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)(</span>numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>i<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
solution <span style="color: #333333;">=</span> displayPermutation<span style="color: #333333;">(</span>NumbersAsString<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>solution <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
solution <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"No solution"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
solution <span style="color: #333333;">=</span> solution <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" is 24"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getSolution</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> solution<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard0</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard1</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard2</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard3</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">displayPermutation</span><span style="color: #333333;">(</span>String s<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0066bb; font-weight: bold;">displayPermutation</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">,</span> s<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">displayPermutation</span><span style="color: #333333;">(</span>String s1<span style="color: #333333;">,</span> String s2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>s2<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> checkValue<span style="color: #333333;">(</span>s1 <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>result <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">=</span> checkValue<span style="color: #333333;">(</span>s1 <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>result <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
String newS2 <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> j <span style="color: #333333;"><</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">();</span> j<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>j <span style="color: #333333;">!=</span> i<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
newS2 <span style="color: #333333;">+=</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>j<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
String result <span style="color: #333333;">=</span> displayPermutation<span style="color: #333333;">(</span>s1 <span style="color: #333333;">+</span> s2<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">),</span> newS2<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>result <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">checkValue</span><span style="color: #333333;">(</span>String value<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">*</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">*</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> op1 <span style="color: #333333;">=</span> i <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> op2 <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>i <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">)</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> op3 <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>i <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">16</span><span style="color: #333333;">)</span> <span style="color: #333333;">%</span> <span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">;</span>
String tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"(("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"))"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"(("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">")"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
tmp <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op3<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op2<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"("</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> getValur<span style="color: #333333;">(</span>op1<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span>value<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"))"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">((</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;"><</span> <span style="color: #6600ee; font-weight: bold;">24.000001</span><span style="color: #333333;">)</span> <span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>evaluateExpression<span style="color: #333333;">(</span>tmp<span style="color: #333333;">)</span> <span style="color: #333333;">></span> <span style="color: #6600ee; font-weight: bold;">23.999999</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> tmp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">char</span> <span style="color: #0066bb; font-weight: bold;">getValur</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> intValue<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">switch</span> <span style="color: #333333;">(</span>intValue<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'+'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'-'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'*'</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">evaluateExpression</span><span style="color: #333333;">(</span>String expression<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> result <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">=</span> evaluateExpression<span style="color: #333333;">(</span>expression<span style="color: #333333;">,</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>Exception ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">evaluateExpression</span><span style="color: #333333;">(</span>String expression<span style="color: #333333;">,</span> ArrayList<span style="color: #333333;"><</span>Integer<span style="color: #333333;">></span> verifyNumbers<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>expression<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Create operandStack to store operands</span>
Stack<span style="color: #333333;"><</span>Double<span style="color: #333333;">></span> operandStack <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Stack<span style="color: #333333;"><</span>Double<span style="color: #333333;">>();</span>
<span style="color: #888888;">// Create operatorStack to store operators</span>
Stack<span style="color: #333333;"><</span>Character<span style="color: #333333;">></span> operatorStack <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> Stack<span style="color: #333333;"><</span>Character<span style="color: #333333;">>();</span>
<span style="color: #888888;">// Insert blanks around (, ), +, -, /, and *</span>
expression <span style="color: #333333;">=</span> insertBlanks<span style="color: #333333;">(</span>expression<span style="color: #333333;">);</span>
<span style="color: #888888;">// Extract operands and operators</span>
String<span style="color: #333333;">[]</span> tokens <span style="color: #333333;">=</span> expression<span style="color: #333333;">.</span><span style="color: #0000cc;">split</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">);</span>
<span style="color: #888888;">// Phase 1: Scan tokens</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span>String token <span style="color: #333333;">:</span> tokens<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #888888;">// Blank space</span>
<span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">continue</span><span style="color: #333333;">;</span> <span style="color: #888888;">// Back to the while loop to extract the next token</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span> <span style="color: #333333;">||</span> token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Process all +, -, *, / in the top of the operator stack</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">()</span>
<span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span>
<span style="color: #333333;">||</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span>
<span style="color: #333333;">||</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span> <span style="color: #333333;">||</span> operatorStack
<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Push the + or - operator into the operator stack</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span> <span style="color: #333333;">||</span> token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Process all *, / in the top of the operator stack</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">()</span>
<span style="color: #333333;">&&</span> <span style="color: #333333;">(</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span> <span style="color: #333333;">||</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Push the * or / operator into the operator stack</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">));</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">().</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'('</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span><span style="color: #0044dd;">'('</span><span style="color: #333333;">);</span> <span style="color: #888888;">// Push '(' to stack</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>token<span style="color: #333333;">.</span><span style="color: #0000cc;">trim</span><span style="color: #333333;">().</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">')'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Process all the operators in the stack until seeing '('</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">peek</span><span style="color: #333333;">()</span> <span style="color: #333333;">!=</span> <span style="color: #0044dd;">'('</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span> <span style="color: #888888;">// Pop the '(' symbol from the stack</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span> <span style="color: #888888;">// An operand scanned</span>
<span style="color: #888888;">// Push an operand to the stack</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Double<span style="color: #333333;">(</span>token<span style="color: #333333;">));</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>verifyNumbers <span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
verifyNumbers<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">(</span>token<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>NumberFormatException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Phase 2: process all the remaining operators in the stack</span>
<span style="color: #008800; font-weight: bold;">while</span> <span style="color: #333333;">(!</span>operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
processAnOperator<span style="color: #333333;">(</span>operandStack<span style="color: #333333;">,</span> operatorStack<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// Return the result</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">isEmpty</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">/**</span>
<span style="color: #888888;"> * Process one operator: Take an operator from operatorStack and apply it on</span>
<span style="color: #888888;"> * the operands in the operandStack</span>
<span style="color: #888888;"> */</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">processAnOperator</span><span style="color: #333333;">(</span>Stack<span style="color: #333333;"><</span>Double<span style="color: #333333;">></span> operandStack<span style="color: #333333;">,</span>
Stack<span style="color: #333333;"><</span>Character<span style="color: #333333;">></span> operatorStack<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">char</span> op <span style="color: #333333;">=</span> operatorStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">double</span> op1 <span style="color: #333333;">=</span> operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #333399; font-weight: bold;">double</span> op2 <span style="color: #333333;">=</span> operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">pop</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">+</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">-</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">*</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>op <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
operandStack<span style="color: #333333;">.</span><span style="color: #0000cc;">push</span><span style="color: #333333;">(</span>op2 <span style="color: #333333;">/</span> op1<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> String <span style="color: #0066bb; font-weight: bold;">insertBlanks</span><span style="color: #333333;">(</span>String s<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'('</span> <span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">')'</span> <span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'+'</span>
<span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'-'</span> <span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'*'</span>
<span style="color: #333333;">||</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> <span style="color: #0044dd;">'/'</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">" "</span> <span style="color: #333333;">+</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">+=</span> s<span style="color: #333333;">.</span><span style="color: #0000cc;">charAt</span><span style="color: #333333;">(</span>i<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise11<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body><h:form><center><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
24-Point Game<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><table><tr></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise11.card0}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise11.card1}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise11.card2}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise11.card3}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"></tr></table></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/><p><font</span> <span style="color: #0000cc;">color =</span> <span style="background-color: #fff0f0;">"#FF0000"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise11.solution}"</span><span style="color: #007700;">/></font></p><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Refresh"</span> <span style="color: #0000cc;">action=</span><span style="background-color: #fff0f0;">"#{exercise11.changeCards()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></h:form></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-12026703360229482862017-03-11T04:43:00.000-08:002017-03-13T02:47:14.968-07:00Chapter 33 Exercise 10, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.10 (Random cards) Write a JSF that displays four random cards from a deck of 52 cards, as shown in Figure 33.33. When the user clicks the Refresh button, four new random cards are displayed.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise10</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">[]</span> deck <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">54</span><span style="color: #333333;">];</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise10</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
changeCards<span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">changeCards</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> deck<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
deck<span style="color: #333333;">[</span>i<span style="color: #333333;">]</span> <span style="color: #333333;">=</span> i <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> deck<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> index <span style="color: #333333;">=</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)</span> <span style="color: #333333;">(</span>Math<span style="color: #333333;">.</span><span style="color: #0000cc;">random</span><span style="color: #333333;">()</span> <span style="color: #333333;">*</span> deck<span style="color: #333333;">.</span><span style="color: #0000cc;">length</span><span style="color: #333333;">);</span>
<span style="color: #333399; font-weight: bold;">int</span> temp <span style="color: #333333;">=</span> deck<span style="color: #333333;">[</span>i<span style="color: #333333;">];</span>
deck<span style="color: #333333;">[</span>i<span style="color: #333333;">]</span> <span style="color: #333333;">=</span> deck<span style="color: #333333;">[</span>index<span style="color: #333333;">];</span>
deck<span style="color: #333333;">[</span>index<span style="color: #333333;">]</span> <span style="color: #333333;">=</span> temp<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard0</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard1</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard2</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCard3</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> deck<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise10<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body><h:form><center><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
Display Four Random Cards<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><table><tr></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise10.card0}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise10.card1}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise10.card2}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width=</span><span style="background-color: #fff0f0;">"100"</span><span style="color: #007700;">><center><h:graphicImage</span> <span style="color: #0000cc;">name=</span><span style="background-color: #fff0f0;">"#{exercise10.card3}.png"</span> <span style="color: #0000cc;">library=</span><span style="background-color: #fff0f0;">"cards"</span><span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"></tr></table></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Refresh"</span> <span style="color: #0000cc;">action=</span><span style="background-color: #fff0f0;">"#{exercise10.changeCards()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></h:form></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-25951350152158249922017-03-11T04:38:00.001-08:002017-03-13T02:46:28.527-07:00Chapter 33 Exercise 9, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.9 (Access and update a Staff table) Write a JSF program that views, inserts, and updates staff information stored in a database, as shown in Figure 33.32. The view button displays a record with a specified ID. The Staff table is created as follows:<br />
<br />
create table Staff (<br />
id char(9) not null,<br />
lastName varchar(15),<br />
firstName varchar(15),<br />
mi char(1),<br />
address varchar(20),<br />
city varchar(20),<br />
state char(2),<br />
telephone char(10),<br />
email varchar(40),<br />
primary key (id)<br />
);<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.Connection</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.DriverManager</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.PreparedStatement</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.ResultSet</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.SQLException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.Statement</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.SessionScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@SessionScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise09</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> Statement statement<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Connection connection<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String lastName <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String firstName <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String mi <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String address <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String city <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String state <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String telephone <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise09</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
Class<span style="color: #333333;">.</span><span style="color: #0000cc;">forName</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"com.mysql.jdbc.Driver"</span><span style="color: #333333;">);</span>
connection <span style="color: #333333;">=</span> DriverManager<span style="color: #333333;">.</span><span style="color: #0000cc;">getConnection</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"jdbc:mysql://localhost/javabook"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"root"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"root"</span><span style="color: #333333;">);</span>
statement <span style="color: #333333;">=</span> connection<span style="color: #333333;">.</span><span style="color: #0000cc;">createStatement</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException <span style="color: #333333;">|</span> ClassNotFoundException ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
ResultSet rset <span style="color: #333333;">=</span> statement<span style="color: #333333;">.</span><span style="color: #0000cc;">executeQuery</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"select * from Staff limit 1;"</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>rset<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
lastName <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">);</span>
firstName <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">);</span>
mi <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">);</span>
address <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">);</span>
city <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">);</span>
state <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">);</span>
telephone <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="color: #333333;">);</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Table is empty"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Table is empty"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">doView</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">((</span>id <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">||</span> <span style="color: #333333;">(</span>id<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">)))</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Enter ID"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
ResultSet rset <span style="color: #333333;">=</span> statement<span style="color: #333333;">.</span><span style="color: #0000cc;">executeQuery</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"select * from Staff where id = "</span> <span style="color: #333333;">+</span> id <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" limit 1;"</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>rset<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
lastName <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">);</span>
firstName <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">);</span>
mi <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">);</span>
address <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">);</span>
city <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">);</span>
state <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">);</span>
telephone <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="color: #333333;">);</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"ID "</span> <span style="color: #333333;">+</span> id <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" not found"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"ID "</span> <span style="color: #333333;">+</span> id <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" not found"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">doInsert</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">((</span>id <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">||</span> <span style="color: #333333;">(</span>id<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">)))</span> <span style="color: #333333;">{</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Enter ID"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
String queryString <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"insert into Staff (id, lastName, firstName, mi, address, city, state, telephone) values (?, ?, ?, ?, ?, ?, ?, ?);"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
PreparedStatement preparedStatement <span style="color: #333333;">=</span> connection<span style="color: #333333;">.</span><span style="color: #0000cc;">prepareStatement</span><span style="color: #333333;">(</span>queryString<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> id<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">,</span> lastName<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">,</span> firstName<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">,</span> mi<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">,</span> address<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">,</span> city<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">,</span> state<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="color: #333333;">,</span> telephone<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">executeUpdate</span><span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException e2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
errorMessage <span style="color: #333333;">=</span> e2<span style="color: #333333;">.</span><span style="color: #0000cc;">getMessage</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">doUpdate</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">((</span>id <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">||</span> <span style="color: #333333;">(</span>id<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">)))</span> <span style="color: #333333;">{</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"ID "</span> <span style="color: #333333;">+</span> id <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" not found"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
String queryString <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"update Staff set lastName = ?, firstName = ?, mi = ?, address = ?, city = ?, state = ?, telephone = ? where id = ?"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
PreparedStatement preparedStatement <span style="color: #333333;">=</span> connection<span style="color: #333333;">.</span><span style="color: #0000cc;">prepareStatement</span><span style="color: #333333;">(</span>queryString<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> lastName<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">,</span> firstName<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">,</span> mi<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">,</span> address<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">,</span> city<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">,</span> state<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">,</span> telephone<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">setString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="color: #333333;">,</span> id<span style="color: #333333;">);</span>
preparedStatement<span style="color: #333333;">.</span><span style="color: #0000cc;">executeUpdate</span><span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException e2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
errorMessage <span style="color: #333333;">=</span> e2<span style="color: #333333;">.</span><span style="color: #0000cc;">getMessage</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">doDelete</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">((</span>id <span style="color: #333333;">==</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)</span> <span style="color: #333333;">||</span> <span style="color: #333333;">(</span>id<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">)))</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Enter ID"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
statement<span style="color: #333333;">.</span><span style="color: #0000cc;">executeUpdate</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"delete from Staff where id = "</span> <span style="color: #333333;">+</span> id <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
ResultSet rset <span style="color: #333333;">=</span> statement<span style="color: #333333;">.</span><span style="color: #0000cc;">executeQuery</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"select * from Staff limit 1;"</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>rset<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
lastName <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">);</span>
firstName <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">);</span>
mi <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">);</span>
address <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">);</span>
city <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">);</span>
state <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">);</span>
telephone <span style="color: #333333;">=</span> rset<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="color: #333333;">);</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Table is empty"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Table is empty"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException ex<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
id <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
resetData<span style="color: #333333;">();</span>
errorMessage <span style="color: #333333;">=</span> ex<span style="color: #333333;">.</span><span style="color: #0000cc;">getMessage</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">resetData</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
lastName <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
firstName <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
mi <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
address <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
city <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
state <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
telephone <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getAddress</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> address<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getCity</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> city<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getFirstName</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> firstName<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getId</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> id<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getLastName</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> lastName<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getMi</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> mi<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getState</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> state<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getTelephone</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> telephone<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getErrorMessage</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> errorMessage<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setAddress</span><span style="color: #333333;">(</span>String address<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">address</span> <span style="color: #333333;">=</span> address<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setCity</span><span style="color: #333333;">(</span>String city<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">city</span> <span style="color: #333333;">=</span> city<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setFirstName</span><span style="color: #333333;">(</span>String firstName<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">firstName</span> <span style="color: #333333;">=</span> firstName<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setId</span><span style="color: #333333;">(</span>String id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">id</span> <span style="color: #333333;">=</span> id<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setLastName</span><span style="color: #333333;">(</span>String lastName<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">lastName</span> <span style="color: #333333;">=</span> lastName<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setMi</span><span style="color: #333333;">(</span>String mi<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">mi</span> <span style="color: #333333;">=</span> mi<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setState</span><span style="color: #333333;">(</span>String state<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">state</span> <span style="color: #333333;">=</span> state<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setTelephone</span><span style="color: #333333;">(</span>String telephone<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">telephone</span> <span style="color: #333333;">=</span> telephone<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise09<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h:form></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><table></span>
<span style="color: #007700;"><tr</span> <span style="color: #0000cc;">align=</span><span style="background-color: #fff0f0;">"center"</span><span style="color: #007700;">><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"50"</span><span style="color: #007700;">><p><font</span> <span style="color: #0000cc;">color =</span> <span style="background-color: #fff0f0;">"#FF0000"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.errorMessage}"</span><span style="color: #007700;">/></font></p></td></tr><tr</span> <span style="color: #0000cc;">align=</span><span style="background-color: #fff0f0;">"left"</span><span style="color: #007700;">><td></span>
<span style="color: #007700;"><fieldset><legend></span>Staff Information<span style="color: #007700;"></legend></span>
<span style="color: #007700;"><p><h:inputText</span> <span style="color: #0000cc;">size =</span> <span style="background-color: #fff0f0;">"5"</span> <span style="color: #0000cc;">style=</span><span style="background-color: #fff0f0;">"background-color: yellow"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.id}"</span> <span style="color: #007700;">/></p></span>
<span style="color: #007700;"><p></span>Last Name: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.lastName}"</span> <span style="color: #007700;">/></span>
First Name: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.firstName}"</span> <span style="color: #007700;">/></span>
MI: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.mi}"</span> <span style="color: #007700;">/></p></span>
<span style="color: #007700;"><p></span>Address: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.address}"</span> <span style="color: #007700;">/></p></span>
<span style="color: #007700;"><p></span>City: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.city}"</span> <span style="color: #007700;">/></span>
State: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">size=</span><span style="background-color: #fff0f0;">"5"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.state}"</span> <span style="color: #007700;">/></p></span>
<span style="color: #007700;"><p></span>Telephone: <span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise09.telephone}"</span> <span style="color: #007700;">/></p></span>
<span style="color: #007700;"></fieldset></td></tr><tr</span> <span style="color: #0000cc;">align=</span><span style="background-color: #fff0f0;">"center"</span><span style="color: #007700;">><td></span>
<span style="color: #007700;"><p><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"View"</span> <span style="color: #0000cc;">action=</span><span style="background-color: #fff0f0;">"#{exercise09.doView()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Insert"</span> <span style="color: #0000cc;">action=</span><span style="background-color: #fff0f0;">"#{exercise09.doInsert()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Update"</span> <span style="color: #0000cc;">action=</span><span style="background-color: #fff0f0;">"#{exercise09.doUpdate()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Delete"</span> <span style="color: #0000cc;">action=</span><span style="background-color: #fff0f0;">"#{exercise09.doDelete()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></p></td></tr></span>
<span style="color: #007700;"></table></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-48764125911004529102017-03-11T04:28:00.001-08:002017-03-13T02:44:26.085-07:00Chapter 33 Exercise 8, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.8 (Guess capitals) Write a JSF that prompts the user to enter a capital for a state, as shown in Figure 33.31a. Upon receiving the user input, the program reports whether the answer is correct, as shown in Figure 33.31b. You can click the Next button to display another question. You can use a two-dimensional array to store the states and capitals, as proposed in Exercise 8.37. Create a list from the array and apply the shuffle method to reorder the list so the questions will appear in random order.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Arrays</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Collections</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.List</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.SessionScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@SessionScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise08</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> String guessedCapital <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> List<span style="color: #333333;"><</span>String<span style="color: #333333;">[]></span> states <span style="color: #333333;">=</span> Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Alabama"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Montgomery"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Alaska"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Juneau"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Arizona"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Phoenix"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Arkansas"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Littlerock"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"California"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Sacramento"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Colorado"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Denver"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Connecticut"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Hartford"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Delaware"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Dover"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Florida"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Tallahassee"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Georgia"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Atlanta"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Hawaii"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Honolulu"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Idaho"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Boise"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Illinois"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Springfield"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Indiana"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Indianapolis"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Iowa"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Des Moines"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Kansas"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Topeka"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Kentucky"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Frankfort"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Louisiana"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Baton Rouge"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Maine"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Augusta"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Maryland"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Annapolis"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Massachusetts"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Boston"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Michigan"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Lansing"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Minnesota"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"St. Paul"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Mississippi"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Jackson"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Missouri"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Jefferson City"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Montana"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Helena"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Nebraska"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Lincoln"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Nevada"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Carson City"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"New Hampshire"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Concord"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"New Jersey"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Trenton"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"New Mexico"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"SantaFe"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"New York"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Albany"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"North Carolina"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Raleigh"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"North Dakota"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Bismarck"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Ohio"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Columbus"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Oklahoma"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Oklahoma City"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Oregon"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Salem"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Pennsylvania"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Harrisburg"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Rhode Island"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Providence"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"South Carolina"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Columbia"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"South Dakota"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Pierre"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Tennessee"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Nashville"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Texas"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Austin"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Utah"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Salt Lake City"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Vermont"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Montpelier"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Virginia"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Richmond"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Washington"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Olympia"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"West Virginia"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Charleston"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Wisconsin"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Madison"</span><span style="color: #333333;">},</span>
<span style="color: #008800; font-weight: bold;">new</span> String<span style="color: #333333;">[]{</span><span style="background-color: #fff0f0;">"Wyoming"</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Cheyenne"</span><span style="color: #333333;">});</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> index <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> correctCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> wrongCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise08</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
Collections<span style="color: #333333;">.</span><span style="color: #0000cc;">shuffle</span><span style="color: #333333;">(</span>states<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getGuessedCapital</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> guessedCapital<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setGuessedCapital</span><span style="color: #333333;">(</span>String guessedCapital<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">guessedCapital</span> <span style="color: #333333;">=</span> guessedCapital<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getState</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>index <span style="color: #333333;">>=</span> states<span style="color: #333333;">.</span><span style="color: #0000cc;">size</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> states<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>index<span style="color: #333333;">)[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getCapital</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>index <span style="color: #333333;">>=</span> states<span style="color: #333333;">.</span><span style="color: #0000cc;">size</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> states<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>index<span style="color: #333333;">)[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">];</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getButtonName</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>index <span style="color: #333333;">>=</span> states<span style="color: #333333;">.</span><span style="color: #0000cc;">size</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
index <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
correctCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
wrongCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
Collections<span style="color: #333333;">.</span><span style="color: #0000cc;">shuffle</span><span style="color: #333333;">(</span>states<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"Restart"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"Next"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">check</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">". The capital of "</span> <span style="color: #333333;">+</span> getState<span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" is "</span> <span style="color: #333333;">+</span> getCapital<span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">".<br><br>"</span><span style="color: #333333;">;</span>
index<span style="color: #333333;">++;</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">((</span>guessedCapital<span style="color: #333333;">!=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">)&&(</span>guessedCapital<span style="color: #333333;">.</span><span style="color: #0000cc;">equals</span><span style="color: #333333;">(</span>states<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>index <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)[</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">])))</span> <span style="color: #333333;">{</span>
correctCount<span style="color: #333333;">++;</span>
result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Yes"</span> <span style="color: #333333;">+</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
wrongCount<span style="color: #333333;">++;</span>
result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"No"</span> <span style="color: #333333;">+</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">"Correct: "</span> <span style="color: #333333;">+</span> correctCount <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br>"</span><span style="color: #333333;">;</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">"Wrong "</span> <span style="color: #333333;">+</span> wrongCount <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br>"</span><span style="color: #333333;">;</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">"Total "</span> <span style="color: #333333;">+</span> states<span style="color: #333333;">.</span><span style="color: #0000cc;">size</span><span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br>"</span><span style="color: #333333;">;</span>
guessedCapital <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise08<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h:form><center><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"What is the capital of #{exercise08.state}? "</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">size =</span> <span style="background-color: #fff0f0;">"20"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise08.guessedCapital}"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Sybmit"</span> <span style="color: #0000cc;">action =</span> <span style="background-color: #fff0f0;">"Exercise08_2"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
<pre style="line-height: 125%; margin: 0;"><span style="background-color: #fff0f0;">Exercise08_2</span></pre>
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise08_2<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h:form><center><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:outputText</span> <span style="color: #0000cc;">escape=</span><span style="background-color: #fff0f0;">"false"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise08.check()}"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise08.buttonName}"</span> <span style="color: #0000cc;">action =</span> <span style="background-color: #fff0f0;">"Exercise08"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-19439003270378207422017-03-11T04:18:00.001-08:002017-03-13T02:42:18.580-07:00Chapter 33 Exercise 7, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.7 (Guess birthday) Listing 4.3, GuessBirthday.java, gives a program for guessing a birthday. Write a JSF program that displays five sets of numbers, as shown in Figure 33.30a. After the user checks the appropriate boxes and clicks the Guess Birthday button, the program displays the birthday, as shown in Figure 33.30b.<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.ArrayList</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Arrays</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.List</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise07</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>Integer<span style="color: #333333;">>>></span> dates <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">private</span> List<span style="color: #333333;"><</span>Boolean<span style="color: #333333;">></span> checked <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise07</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>Integer<span style="color: #333333;">>></span> tmpList <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">9</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">11</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">13</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">15</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">17</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">19</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">21</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">25</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">27</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">29</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">31</span><span style="color: #333333;">}));</span>
dates<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>tmpList<span style="color: #333333;">);</span>
tmpList <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">11</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">14</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">15</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">18</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">19</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">22</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">26</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">27</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">31</span><span style="color: #333333;">}));</span>
dates<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>tmpList<span style="color: #333333;">);</span>
tmpList <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">4</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">6</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">7</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">12</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">13</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">14</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">15</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">21</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">22</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">28</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">29</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">31</span><span style="color: #333333;">}));</span>
dates<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>tmpList<span style="color: #333333;">);</span>
tmpList <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">8</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">9</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">11</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">12</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">13</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">14</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">15</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">24</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">25</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">26</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">27</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">28</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">29</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">31</span><span style="color: #333333;">}));</span>
dates<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>tmpList<span style="color: #333333;">);</span>
tmpList <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><>();</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">16</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">17</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">18</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">19</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">21</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">22</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">23</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">24</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">25</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">26</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">27</span><span style="color: #333333;">}));</span>
tmpList<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Arrays<span style="color: #333333;">.</span><span style="color: #0000cc;">asList</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Integer<span style="color: #333333;">[]{</span><span style="color: #0000dd; font-weight: bold;">28</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">29</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">30</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">31</span><span style="color: #333333;">}));</span>
dates<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>tmpList<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> <span style="color: #0000dd; font-weight: bold;">5</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
checked<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span>Boolean<span style="color: #333333;">.</span><span style="color: #0000cc;">FALSE</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setChecked</span><span style="color: #333333;">(</span>List<span style="color: #333333;"><</span>Boolean<span style="color: #333333;">></span> checked<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">checked</span> <span style="color: #333333;">=</span> checked<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setDates</span><span style="color: #333333;">(</span>List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>Integer<span style="color: #333333;">>>></span> dates<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">dates</span> <span style="color: #333333;">=</span> dates<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> List<span style="color: #333333;"><</span>Boolean<span style="color: #333333;">></span> <span style="color: #0066bb; font-weight: bold;">getChecked</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> checked<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>List<span style="color: #333333;"><</span>Integer<span style="color: #333333;">>>></span> <span style="color: #0066bb; font-weight: bold;">getDates</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> dates<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getDay</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> day <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> checked<span style="color: #333333;">.</span><span style="color: #0000cc;">size</span><span style="color: #333333;">();</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>checked<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>i<span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
day <span style="color: #333333;">+=</span> dates<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>i<span style="color: #333333;">).</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">).</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>day <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"Your birth day is "</span> <span style="color: #333333;">+</span> day<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span>
<span style="color: #0000cc;">xmlns:ui=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/facelets"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise07<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h:form></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><table></span>
<span style="color: #007700;"><tr><td</span> <span style="color: #0000cc;">colspan=</span><span style="background-color: #fff0f0;">"5"</span><span style="color: #007700;">><center></span>Check the boxes if your birthday is in these sets<span style="color: #007700;"></center></td></tr></span>
<span style="color: #007700;"><tr></span>
<span style="color: #007700;"><ui:repeat</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise07.dates}"</span> <span style="color: #0000cc;">var=</span><span style="background-color: #fff0f0;">"dates1"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width =</span> <span style="background-color: #fff0f0;">"120"</span><span style="color: #007700;">><fieldset><table></span>
<span style="color: #007700;"><ui:repeat</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{dates1}"</span> <span style="color: #0000cc;">var=</span><span style="background-color: #fff0f0;">"dates2"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><tr></span>
<span style="color: #007700;"><ui:repeat</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{dates2}"</span> <span style="color: #0000cc;">var=</span><span style="background-color: #fff0f0;">"dates3"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width =</span> <span style="background-color: #fff0f0;">"20"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{dates3}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"></ui:repeat></span>
<span style="color: #007700;"></tr></span>
<span style="color: #007700;"></ui:repeat></span>
<span style="color: #007700;"></table></fieldset></td></span>
<span style="color: #007700;"></ui:repeat></span>
<span style="color: #007700;"></tr></span>
<span style="color: #007700;"><tr></span>
<span style="color: #007700;"><ui:repeat</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise07.checked}"</span> <span style="color: #0000cc;">var=</span><span style="background-color: #fff0f0;">"checked"</span> <span style="color: #0000cc;">varStatus=</span><span style="background-color: #fff0f0;">"loop"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">width =</span> <span style="background-color: #fff0f0;">"120"</span><span style="color: #007700;">><center><h:selectBooleanCheckbox</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise07.checked[loop.index]}"</span> <span style="color: #007700;">/></center></td></span>
<span style="color: #007700;"></ui:repeat></span>
<span style="color: #007700;"></tr></span>
<span style="color: #007700;"></table><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><input</span> <span style="color: #0000cc;">type =</span> <span style="background-color: #fff0f0;">"submit"</span> <span style="color: #0000cc;">value =</span> <span style="background-color: #fff0f0;">"Find date"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/><h:outputLabel</span> <span style="color: #0000cc;">style=</span><span style="background-color: #fff0f0;">"color:red"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise07.getDay()}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-9064037730714301162017-03-11T04:13:00.001-08:002017-03-13T02:41:02.835-07:00Chapter 33 Exercise 6, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.6 (Large factorial) Rewrite Exercise 33.1 to handle large factorial. Use the<br />
BigInteger class introduced in Section 10.9.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.math.BigInteger</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise06</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> number<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> number<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> newValue<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
number <span style="color: #333333;">=</span> newValue<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getFactorial</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
BigInteger factorial <span style="color: #333333;">=</span> BigInteger<span style="color: #333333;">.</span><span style="color: #0000cc;">ONE</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> number<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
factorial <span style="color: #333333;">=</span> factorial<span style="color: #333333;">.</span><span style="color: #0000cc;">multiply</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> BigInteger<span style="color: #333333;">(</span>i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> factorial<span style="color: #333333;">.</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise06<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h3></span>Compute Factorial Using a Bean<span style="color: #007700;"></h3></span>
<span style="color: #007700;"><h:form></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Enter new value: "</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">size =</span> <span style="background-color: #fff0f0;">"10"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise06.number}"</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Compute Factorial"</span><span style="color: #007700;">/><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
Factorial of <span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise06.number}"</span><span style="color: #007700;">/></span> is <span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise06.factorial}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-32238265064470666292017-03-11T04:10:00.001-08:002017-03-13T02:29:49.871-07:00Chapter 33 Exercise 5, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.5 (Addition quiz) Write a JSF program that generates addition quizzes randomly, as shown in Figure 33.29a. After the user answers all questions, it displays the result, as shown in Figure 33.29b.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.ArrayList</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.List</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.SessionScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@SessionScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise05</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> size <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> List<span style="color: #333333;"><</span>Numbers<span style="color: #333333;">></span> numbers <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayList<span style="color: #333333;"><</span>Numbers<span style="color: #333333;">>();</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> correctCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise05</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
renew<span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">renew</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">clear</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><</span> size<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
numbers<span style="color: #333333;">.</span><span style="color: #0000cc;">add</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> Numbers<span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
correctCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> List<span style="color: #333333;"><</span>Numbers<span style="color: #333333;">></span> <span style="color: #0066bb; font-weight: bold;">getNumbers</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> numbers<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getCorrectCount</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> correctCount<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">resetCorrectCount</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
correctCount <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getSize</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> size<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Numbers</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> number1<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> number2<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> result<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String guess <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">""</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Numbers</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
number1 <span style="color: #333333;">=</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)(</span>Math<span style="color: #333333;">.</span><span style="color: #0000cc;">random</span><span style="color: #333333;">()</span> <span style="color: #333333;">*</span> <span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">);</span>
number2 <span style="color: #333333;">=</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span><span style="color: #333333;">)(</span>Math<span style="color: #333333;">.</span><span style="color: #0000cc;">random</span><span style="color: #333333;">()</span> <span style="color: #333333;">*</span> <span style="color: #0000dd; font-weight: bold;">20</span><span style="color: #333333;">);</span>
result <span style="color: #333333;">=</span> number1 <span style="color: #333333;">+</span> number2<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Numbers</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> number1<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> number2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">number1</span> <span style="color: #333333;">=</span> number1<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">number2</span> <span style="color: #333333;">=</span> number2<span style="color: #333333;">;</span>
result <span style="color: #333333;">=</span> number1 <span style="color: #333333;">+</span> number2<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber1</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> number1<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumber2</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> number2<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getResult</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getGuess</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> guess<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber1</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> number1<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">number1</span> <span style="color: #333333;">=</span> number1<span style="color: #333333;">;</span>
result <span style="color: #333333;">=</span> number1 <span style="color: #333333;">+</span> number2<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumber2</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> number2<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">number2</span> <span style="color: #333333;">=</span> number2<span style="color: #333333;">;</span>
result <span style="color: #333333;">=</span> number1 <span style="color: #333333;">+</span> number2<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setGuess</span><span style="color: #333333;">(</span>String guess<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">guess</span> <span style="color: #333333;">=</span> guess<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">check</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span><span style="color: #333333;">(</span>Integer<span style="color: #333333;">.</span><span style="color: #0000cc;">parseInt</span><span style="color: #333333;">(</span>guess<span style="color: #333333;">)</span> <span style="color: #333333;">==</span> result<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
correctCount<span style="color: #333333;">++;</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"Correct"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"Wrong"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>NumberFormatException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"Wrong"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://java.sun.com/jsf/html"</span>
<span style="color: #0000cc;">xmlns:ui=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/facelets"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise05<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><h:form></span>
<span style="color: #007700;"><table></span>
<span style="color: #007700;"><ui:repeat</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise05.numbers}"</span> <span style="color: #0000cc;">var=</span><span style="background-color: #fff0f0;">"number"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><tr></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.number1}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"+"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.number2}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"="</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:inputText</span> <span style="color: #0000cc;">size =</span> <span style="background-color: #fff0f0;">"3"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.guess}"</span> <span style="color: #007700;">/></td></span>
<span style="color: #007700;"></tr></span>
<span style="color: #007700;"></ui:repeat></span>
<span style="color: #007700;"></table></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Submit"</span> <span style="color: #0000cc;">action =</span> <span style="background-color: #fff0f0;">"Exercise05_2"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Generate New Questions"</span> <span style="color: #0000cc;">action =</span> <span style="background-color: #fff0f0;">"#{exercise05.renew}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
Exercise05_2
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://java.sun.com/jsf/html"</span>
<span style="color: #0000cc;">xmlns:ui=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/facelets"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise05_2<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><table></span>
<span style="color: #007700;"><ui:repeat</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise05.numbers}"</span> <span style="color: #0000cc;">var=</span><span style="background-color: #fff0f0;">"number"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><tr></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.number1}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"+"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.number2}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"="</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.guess}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"><td</span> <span style="color: #0000cc;">height=</span><span style="background-color: #fff0f0;">"30"</span><span style="color: #007700;">><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{number.check()}"</span><span style="color: #007700;">/></td></span>
<span style="color: #007700;"></tr></span>
<span style="color: #007700;"></ui:repeat></span>
<span style="color: #007700;"></table></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
There are <span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise05.correctCount}"</span><span style="color: #007700;">/></span> correct guesses
#{exercise05.resetCorrectCount()}
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-39871020217315937562017-03-11T04:05:00.001-08:002017-03-13T02:24:50.950-07:00Chapter 33 Exercise 4, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.4 (Calculate loan) Write a JSF page that lets the user enter loan amount, interest rate, and number of years, as shown in Figure 33.28a. Click the Compute Loan Payment button to compute and display the monthly and total loan payments, as shown in Figure 33.28b. Use the Loan class given in Listing 10.2, Loan.java, to compute the monthly and total payments.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise04</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">double</span> annualInterestRate<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> numberOfYears<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">double</span> loanAmount<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Date</span> loanDate<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise04</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">,</span> <span style="color: #0000dd; font-weight: bold;">1000</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">Exercise04</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">double</span> annualInterestRate<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> numberOfYears<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">double</span> loanAmount<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">annualInterestRate</span> <span style="color: #333333;">=</span> annualInterestRate<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">numberOfYears</span> <span style="color: #333333;">=</span> numberOfYears<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">loanAmount</span> <span style="color: #333333;">=</span> loanAmount<span style="color: #333333;">;</span>
loanDate <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Date</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">getAnnualInterestRate</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> annualInterestRate<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setAnnualInterestRate</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">double</span> annualInterestRate<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">annualInterestRate</span> <span style="color: #333333;">=</span> annualInterestRate<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getNumberOfYears</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> numberOfYears<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setNumberOfYears</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> numberOfYears<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">numberOfYears</span> <span style="color: #333333;">=</span> numberOfYears<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">getLoanAmount</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> loanAmount<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setLoanAmount</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">double</span> loanAmount<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">loanAmount</span> <span style="color: #333333;">=</span> loanAmount<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">getMonthlyPayment</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> monthlyInterestRate <span style="color: #333333;">=</span> annualInterestRate <span style="color: #333333;">/</span> <span style="color: #0000dd; font-weight: bold;">1200</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">double</span> monthlyPayment <span style="color: #333333;">=</span> loanAmount <span style="color: #333333;">*</span> monthlyInterestRate <span style="color: #333333;">/</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span>
<span style="color: #333333;">-</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span> <span style="color: #333333;">/</span> Math<span style="color: #333333;">.</span><span style="color: #0000cc;">pow</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">1</span> <span style="color: #333333;">+</span> monthlyInterestRate<span style="color: #333333;">,</span> numberOfYears <span style="color: #333333;">*</span> <span style="color: #0000dd; font-weight: bold;">12</span><span style="color: #333333;">)));</span>
<span style="color: #008800; font-weight: bold;">return</span> monthlyPayment<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">getTotalPayment</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> totalPayment <span style="color: #333333;">=</span> getMonthlyPayment<span style="color: #333333;">()</span> <span style="color: #333333;">*</span> numberOfYears <span style="color: #333333;">*</span> <span style="color: #0000dd; font-weight: bold;">12</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">return</span> totalPayment<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> java<span style="color: #333333;">.</span><span style="color: #0000cc;">util</span><span style="color: #333333;">.</span><span style="color: #0000cc;">Date</span> <span style="color: #0066bb; font-weight: bold;">getLoanDate</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> loanDate<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getInput</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="background-color: #fff0f0;">"<p style=\"color:red\"><br />"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"Loan Amount: "</span> <span style="color: #333333;">+</span> loanAmount <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br />"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"Annual Interest Rate: "</span> <span style="color: #333333;">+</span> annualInterestRate <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br />"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"Number Of Years: "</span> <span style="color: #333333;">+</span> numberOfYears <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br />"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"Monthly Payment: "</span> <span style="color: #333333;">+</span> getMonthlyPayment<span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<br />"</span>
<span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"Total Payment: "</span> <span style="color: #333333;">+</span> getTotalPayment<span style="color: #333333;">()</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</p>"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://java.sun.com/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise04<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h:form></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><h3></span>
Compute Loan Payment
<span style="color: #007700;"></h3></span>
<span style="color: #007700;"><h:panelGrid</span> <span style="color: #0000cc;">columns=</span><span style="background-color: #fff0f0;">"2"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Loan Amount"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"amount"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise04.loanAmount}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Annual Interest Rate"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"rate"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise04.annualInterestRate}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Number Of Years"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"years"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise04.numberOfYears}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></h:panelGrid></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Compute Loan Payment"</span> <span style="color: #0000cc;">action =</span> <span style="background-color: #fff0f0;">"Exercise04_2"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
Exercise04_2
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise02<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><h:outputText</span> <span style="color: #0000cc;">escape=</span><span style="background-color: #fff0f0;">"false"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise02.table}"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com1tag:blogger.com,1999:blog-619838397038898011.post-6560452009348569962017-03-11T03:59:00.002-08:002017-03-13T02:20:01.146-07:00Chapter 33 Exercise 3, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.3 (Calculate tax) Write a JSF page to let the user enter taxable income and filing status, as shown in Figure 33.27a. Clicking the Compute Tax button computes and displays the tax, as shown in Figure 33.27b. Use the computeTax method introduced in Listing 3.5, ComputeTax.java, to compute tax.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise03</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">int</span> status<span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">double</span> income<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">int</span> <span style="color: #0066bb; font-weight: bold;">getStatus</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> status<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setStatus</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> status<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">status</span> <span style="color: #333333;">=</span> status<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">getIncome</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> income<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">setIncome</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">double</span> income<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">.</span><span style="color: #0000cc;">income</span> <span style="color: #333333;">=</span> income<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">getTax</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0066bb; font-weight: bold;">computetax</span><span style="color: #333333;">(</span>status<span style="color: #333333;">,</span> income<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">double</span> <span style="color: #0066bb; font-weight: bold;">computetax</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> status<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">double</span> income<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333399; font-weight: bold;">double</span> tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>status <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span> <span style="color: #888888;">// Compute tax for single filers</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> income <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">82250</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">171550</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">82250</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">82250</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">372950</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">82250</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">171550</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">82250</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">171550</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">82250</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">171550</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">82250</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">372950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">171550</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">372950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.35</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>status <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span> <span style="color: #888888;">// Compute tax for married file jointly</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">16700</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> income <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">67900</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">16700</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">16700</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">137050</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">16700</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">67900</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">16700</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">67900</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">208850</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">16700</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">67900</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">16700</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">82250</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">67900</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">137050</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">372950</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">16700</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">67900</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">16700</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">82250</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">67900</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">208850</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">137050</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">208850</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">16700</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">67900</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">16700</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">82250</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">67900</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">208850</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">137050</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">372950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">208850</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">372950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.35</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>status <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">2</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span> <span style="color: #888888;">// Compute tax for married separately</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> income <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">68525</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">104425</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">68525</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">68525</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">186475</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">68525</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">104425</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">68525</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">104425</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">8350</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">33950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">8350</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">68525</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">33950</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">104425</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">68525</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">186475</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">104425</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">186475</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.35</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>status <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span> <span style="color: #888888;">// Compute tax for head of household</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">11950</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> income <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">45500</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">11950</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">11950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">117450</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">11950</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">45500</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">11950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">45500</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">190200</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">11950</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">45500</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">11950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">117450</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">45500</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">117450</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>income <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">372950</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">11950</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">45500</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">11950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">117450</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">45500</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">190200</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">117450</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">190200</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
tax <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">11950</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.10</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">45500</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">11950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.15</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">117450</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">45500</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.25</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">190200</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">117450</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.28</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">372950</span> <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">190200</span><span style="color: #333333;">)</span>
<span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.33</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>income <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">372950</span><span style="color: #333333;">)</span> <span style="color: #333333;">*</span> <span style="color: #6600ee; font-weight: bold;">0.35</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">throw</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">IllegalArgumentException</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Invalid status"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> tax<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://java.sun.com/jsf/html"</span>
<span style="color: #0000cc;">xmlns:f=</span><span style="background-color: #fff0f0;">"http://java.sun.com/jsf/core"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise03<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><h:form></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><h3></span>
Compute Tax
<span style="color: #007700;"></h3></span>
<span style="color: #007700;"><h:panelGrid</span> <span style="color: #0000cc;">columns=</span><span style="background-color: #fff0f0;">"2"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Taxable income"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:inputText</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"income"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise03.income}"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></h:panelGrid></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:panelGrid</span> <span style="color: #0000cc;">columns=</span><span style="background-color: #fff0f0;">"2"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:outputLabel</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Filing status "</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><h:selectOneMenu</span> <span style="color: #0000cc;">id=</span><span style="background-color: #fff0f0;">"status"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise03.status}"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue=</span><span style="background-color: #fff0f0;">"0"</span> <span style="color: #0000cc;">itemLabel=</span><span style="background-color: #fff0f0;">"single filer"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue=</span><span style="background-color: #fff0f0;">"1"</span> <span style="color: #0000cc;">itemLabel=</span><span style="background-color: #fff0f0;">"married jointly or qualifying widow(er)"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue=</span><span style="background-color: #fff0f0;">"2"</span> <span style="color: #0000cc;">itemLabel=</span><span style="background-color: #fff0f0;">"married separately"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"><f:selectItem</span> <span style="color: #0000cc;">itemValue=</span><span style="background-color: #fff0f0;">"3"</span> <span style="color: #0000cc;">itemLabel=</span><span style="background-color: #fff0f0;">"head of household"</span><span style="color: #007700;">/></span>
<span style="color: #007700;"></h:selectOneMenu></span>
<span style="color: #007700;"></h:panelGrid></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:commandButton</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"Compute Tax"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><br</span> <span style="color: #007700;">/><br</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"><h:outputText</span> <span style="color: #0000cc;">escape=</span><span style="background-color: #fff0f0;">"false"</span> <span style="color: #0000cc;">style=</span><span style="background-color: #fff0f0;">"color:red"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise03.tax}"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:form></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-43839121100934435152017-03-11T03:54:00.002-08:002017-03-13T02:18:37.232-07:00Chapter 33 Exercise 2, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.2 (Multiplication table) Write a JSF page that displays a multiplication table as shown in Figure 33.26.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise02</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getTable</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"<table align=\"center\" border=\"1\">"</span><span style="color: #333333;">;</span>
<span style="color: #333399; font-weight: bold;">int</span> tableSize <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">9</span><span style="color: #333333;">;</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<tr><td colspan="</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>tableSize <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">" align=\"center\" bgcolor=\"#cccccc\" height=30><b>Multiplication table</b></td></tr>"</span><span style="color: #333333;">;</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<tr><td width=\"40\" bgcolor=\"#cccccc\"></td>"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> tableSize<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<td align=\"center\" width=\"40\" bgcolor=\"#cccccc\" >"</span> <span style="color: #333333;">+</span> i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</td>"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</tr>"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> tableSize<span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<tr><td align=\"center\" bgcolor=\"#cccccc\" >"</span> <span style="color: #333333;">+</span> i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</td>"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> j <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span> j <span style="color: #333333;"><=</span> tableSize<span style="color: #333333;">;</span> j<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"<td align=\"center\" >"</span> <span style="color: #333333;">+</span> <span style="color: #333333;">(</span>i <span style="color: #333333;">*</span> j<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</td>"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</tr>"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">=</span> result <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</table>"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">long</span> <span style="color: #0066bb; font-weight: bold;">computeFactorial</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> n<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>n <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> n <span style="color: #333333;">*</span> computeFactorial<span style="color: #333333;">(</span>n <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise02<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><h:outputText</span> <span style="color: #0000cc;">escape=</span><span style="background-color: #fff0f0;">"false"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise02.table}"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0tag:blogger.com,1999:blog-619838397038898011.post-21404448689036118062017-03-11T03:48:00.002-08:002017-03-13T02:17:24.252-07:00Chapter 33 Exercise 1, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.<div dir="ltr" style="text-align: left;" trbidi="on">
33.1 (Factorial table in JSF) Write a JSF page that displays a factorial page as<br />
shown in Figure 33.25. Display the table in an h:outputText component. Set<br />
its escape property to false to display it as HTML contents.<br />
<br />
<br />
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.ManagedBean</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">javax.faces.bean.RequestScoped</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@ManagedBean</span>
<span style="color: #555555; font-weight: bold;">@RequestScoped</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">Exercise01</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">getTable</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
String result <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"<h1><b>Display Factorials!</b></h1><table border=\"1\"><tr><td>Number</td><td>Factorial</td></tr>"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">for</span> <span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> i <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">;</span> i <span style="color: #333333;"><=</span> <span style="color: #0000dd; font-weight: bold;">10</span><span style="color: #333333;">;</span> i<span style="color: #333333;">++)</span> <span style="color: #333333;">{</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">"<tr><td>"</span> <span style="color: #333333;">+</span> i <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</td><td>"</span> <span style="color: #333333;">+</span> computeFactorial<span style="color: #333333;">(</span>i<span style="color: #333333;">)</span> <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">"</td></tr>"</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
result <span style="color: #333333;">+=</span> <span style="background-color: #fff0f0;">"</table>"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">return</span> result<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">long</span> <span style="color: #0066bb; font-weight: bold;">computeFactorial</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> n<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>n <span style="color: #333333;">==</span> <span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">return</span> n <span style="color: #333333;">*</span> computeFactorial<span style="color: #333333;">(</span>n <span style="color: #333333;">-</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</div>
<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #557799;"><?xml version='1.0' encoding='UTF-8' ?></span>
<span style="color: #557799;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></span>
<span style="color: #007700;"><html</span> <span style="color: #0000cc;">xmlns=</span><span style="background-color: #fff0f0;">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #0000cc;">xmlns:h=</span><span style="background-color: #fff0f0;">"http://xmlns.jcp.org/jsf/html"</span><span style="color: #007700;">></span>
<span style="color: #007700;"><h:head></span>
<span style="color: #007700;"><title></span>Exercise01<span style="color: #007700;"></title></span>
<span style="color: #007700;"></h:head></span>
<span style="color: #007700;"><h:body></span>
<span style="color: #007700;"><center></span>
<span style="color: #007700;"><h:outputText</span> <span style="color: #0000cc;">escape=</span><span style="background-color: #fff0f0;">"false"</span> <span style="color: #0000cc;">value=</span><span style="background-color: #fff0f0;">"#{exercise01.table}"</span> <span style="color: #007700;">/></span>
<span style="color: #007700;"></center></span>
<span style="color: #007700;"></h:body></span>
<span style="color: #007700;"></html></span>
</pre>
</div>
</div>
Ghost Henryhttp://www.blogger.com/profile/08996728742859917234noreply@blogger.com0