Programming 360’s Post

View organization page for Programming 360, graphic

244 followers

#Programming #Algorithms #Education #HelpNeeded Hey everyone! 🌟 I’m in a bit of a pickle and could really use your insights. We’ve been discussing algorithms in my intro programming class, and we hit a snag with this loop question: x = 7 do: x = x - 2 while x > 4 The big question is: How many iterations does this algorithm have? 🤔 So, here’s the deal. My professor insists there’s only one iteration, claiming the other doesn't count. But to me, that doesn't add up. Here’s why I think it does: First iteration: Starts with x = 7. The loop runs, subtracting 2 from 7, giving us x = 5. Second iteration: Now, x = 5. The loop checks the condition and still runs, subtracting 2 again, which results in x = 3. The loop stops running when x becomes 3, which is not greater than 4. So, I counted two iterations! Isn’t that how we should track it? What I’m really hoping for is some solid resources or reputable books on counting loop iterations. 📚 I want to back up my point of view wit... How Can I Convince My Professor on Loop Iteration Counting? Answers: https://lnkd.in/geqzGMTM

To view or add a comment, sign in

Explore topics