Consider the algorithm below.
In order, the values printed by the algorithm are
- \( 12\)
- \( 12,7\)
- \(12,7,2\)
- \(12,7,2,-3\)
Aussie Maths & Science Teachers: Save your time with SmarterEd
Consider the algorithm below.
In order, the values printed by the algorithm are
\(C\)
\(n=17, k=5, n>k\)
\(n=12, k=5, \ \text{print}\ 12, n>k\)
\(n=7, k=5, \ \text{print} \ 7, n>k\)
\(n=2, k=5, \ \text{print}\ 2, n<k \text { end while}\)
\(\text { Printed values:}\ 12,7,2\)
\(\Rightarrow C\)
Consider the algorithm below, which prints the roots of the cubic polynomial \(f(x)=x^3-2 x^2-9 x+18\).
\begin{array} {l}
\rule{0pt}{2.5ex} \textbf{ define} \ \text{ f (x) } \\
\rule{0pt}{2.5ex} \quad \quad \textbf{return} \ \text{(x} ^3 - 2 \text{x}^2 - 9 \text{x} + 18) \\
\rule{0pt}{2.5ex} \text{c} \leftarrow \text{f} \ (0) \\
\rule{0pt}{2.5ex} \textbf{if}\ \ \text{c < 0} \ \textbf{then}\\
\rule{0pt}{2.5ex} \quad \quad \text{c} \ \leftarrow \ \text{(- c)} \\
\rule{0pt}{2.5ex} \textbf{end if} \\
\rule{0pt}{2.5ex} \textbf{while} \ \text{ c > 0 } \\
\rule{0pt}{2.5ex} \quad \quad \textbf{if} \ \ \text{f (c) = 0 } \ \textbf{then} \\
\rule{0pt}{2.5ex} \quad \quad \quad \quad \textbf{print} \ \text{c } \\
\rule{0pt}{2.5ex} \quad \quad \textbf{end if} \\
\rule{0pt}{2.5ex} \quad \quad \textbf{if} \ \ \text{f (-c) = 0} \ \textbf{then} \\
\rule{0pt}{2.5ex} \quad \quad \quad \quad \textbf{print} \ \text{-c } \\
\rule{0pt}{2.5ex} \quad \quad \textbf{end if} \\
\rule{0pt}{2.5ex} \quad \quad \text{c} \ \leftarrow \ \text{c - 1} \\
\rule{0pt}{2.5ex} \textbf{ end while } \\
\end{array}
In order, the algorithm prints the values
\(D\)
\(\text{Solve}\ \ \ x^3-2 x^2-9 x+18=0\ \ \text{(using CAS):}\)
\(\text{Roots are:}\ \ \ x=3,\ 2, -3\)
\(\text{Using the algorithm the order is }\ c, -c,\ c-1\ \rightarrow \ 3, -3,\ 2\)
\(\Rightarrow D\)
Consider the algorithm below, which uses the bisection method to estimate the solution to an equation in the form \(f(x)=0\).
The algorithm is implemented as follows.
Which value would be returned when the algorithm is implemented as given?
\(D\)
\(\textbf{Define }\text{bisection}\ (f(x),a,b,\max)\ \rightarrow\ (\sin(x), 3, 5, 2)\)
\(\text{Test for }\ i=0, 1\ \rightarrow i<\max=2\)
| \(i=0\quad\) | \(\text{mid}\) | \(=\dfrac{3+5}{2}\) | \(=4\quad [\sin(4)<0\ \text{ and }\ \sin(3)\times\sin(4)<0]\) |
| \(i=1\quad\) | \(\text{mid}\) | \(=\dfrac{3+4}{2}\) | \(=3.5\quad [\sin(3.5)<0\ \text{ and }\ \sin(3)\times\sin(3.5)<0]\) |
\(\Rightarrow D\)