A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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.

  • This Question is Closed
  1. ChillOut
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Each 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.

  2. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    got it!! the answer is 60

  3. ChillOut
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    How's it? Please give your solution.

  4. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    value of i = 4 for j = 3 for k = 6 x 2 4(3 + (6x2)) =60

  5. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i don't know if it makes sense. but I got it right!

  6. ChillOut
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Nope. 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

  7. ChillOut
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Do you understand any programming languages?

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.