A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 one year ago
Consider the following algorithm.
for
i is in {1, 2, 3, 4} do
beep
for j is in {1, 2, 3, 4} do
beep
for k is in {1, 2, 3} do
for l is in {1, 2, 3, 4, 5, 6} do
beep
for m is in {1, 2, 3, 4, 5} do
beep
How many times does a beep statement get executed?
anonymous
 one year ago
Consider the following algorithm. for i is in {1, 2, 3, 4} do beep for j is in {1, 2, 3, 4} do beep for k is in {1, 2, 3} do for l is in {1, 2, 3, 4, 5, 6} do beep for m is in {1, 2, 3, 4, 5} do beep How many times does a beep statement get executed?

This Question is Closed

IrishBoy123
 one year ago
Best ResponseYou've already chosen the best response.1check the indents which are absolutely crucial but indexed like this in Python ==> **152** times x = 0 for i in range(1,5): x+=1 for j in range(1,5): x+=1 for k in range(1,4): for l in range(1,7): x+=1 for m in range(1,6): x+=1 print x NB "range" doesn't run on the last item in Python so range(1,5) \(\equiv\) {1,2,3,4} assuming that is how your source works

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0Thank you! I tried calculating, but did not get it. So, I have to add 1 to every range? and then add them all together and multiply by 4? is that how you got the final answer?

IrishBoy123
 one year ago
Best ResponseYou've already chosen the best response.1no i just rewrote the instructions in Python and ran it you could work it out by hand, of course you could.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.