A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 one year ago
Consider the following algorithm.
x ← 1
for i is in {1, 2, 3, 4} do
for j is in {1, 2, 3} do
x ← x + x
for k is in {1, 2, 3, 4, 5, 6} do
x ← x + 1
x ← x + 5
Count the number of + operations done by this algorithm.
anonymous
 one year ago
Consider the following algorithm. x ← 1 for i is in {1, 2, 3, 4} do for j is in {1, 2, 3} do x ← x + x for k is in {1, 2, 3, 4, 5, 6} do x ← x + 1 x ← x + 5 Count the number of + operations done by this algorithm.

This Question is Closed

ChillOut
 one year ago
Best ResponseYou've already chosen the best response.0Each outside loop will run the insider loop for every iteration. the "k" loop is inside the "j" loop, which in turn is inside the "i" loop. As it turns out, for every iteration of "j", we will have 1 + (6*2) = 13 operations. As we have 3 "j" iterations, this gives 39 "+" operations for each "i" iteration. So, for 4 "i" iterations, we have 4*39 = 156 "+" operations.

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0got it!! the answer is 60

ChillOut
 one year ago
Best ResponseYou've already chosen the best response.0How's it? Please give your solution.

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0value of i = 4 for j = 3 for k = 6 x 2 4(3 + (6x2)) =60

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0i don't know if it makes sense. but I got it right!

ChillOut
 one year ago
Best ResponseYou've already chosen the best response.0Nope. I just tested it. Check it at http://ideone.com/GsQ3pj You should be able to understand. The program output is Success time: 0 memory: 3096 signal:0 156

ChillOut
 one year ago
Best ResponseYou've already chosen the best response.0Do you understand any programming languages?
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.