6.
-11 points HunterDM3 4.5.010b.
Consider the following algorithm.
x1
for i E {1, 2, 3) do
for je {1, 2, 3, 4} do
XX+X
for ke {1, 2, 3, 4, 5} do
XX + 2
Г
L XX + 4
What is the value of x after the algorithm finishes?
onaal
2.
+ -/1 points HunterDM3 4.5.006.
Consider the following algorithm.
for i E{1, 2, 3, 4, 5} do
beep
Г
for je{1, 2, 3} do
beep
for ke {1, 2, 3,4} do
for le {1, 2, 3, 4, 5, 6} do
beep
for me{1, 2, 3, 4} do
beep
How many times does a beep statement get executed?
L
L
eBook
5.
-11 points HunterDM3 4.5.010a.
Consider the following algorithm.
x=1
for i E{1, 2, 3} do
for je{1, 2, 3, 4} do
X-X + X
for ke {1, 2, 3, 4, 5, 6} do
rXX+ 1
Г
L
L XX + 5
Count the number of + operations done by this algorithm.
eBook
1.
+ -/1 points HunterDM3 4.5.004.
My Notes + Ask Your Teacher
Let x and n be integers greater than 1. Consider the following algorithm.
te 0,50
for i E{1, 2, ... , *} do
for ; E {1, 2, ..., n} do
t-t+X
LSS+t
// line A
Ther and L symbols and the indentation are important: they tell you which lines are inside which loop. So, for example, line A is inside the i-loop, but outside the j-loop.
(a) If x = 4 and n = 5 initially, what is the value of s after this segment executes?
(b) Count the number of additions this segment performs. Your answer should be in terms of x and n.
eBook
Purchase answer to see full
attachment