Question: Can someone help me understand this better. I'm not sure why the answer is not 5. What is the exact number of statements that get

Can someone help me understand this better. I'm not sure why the answer is not 5.

What is the exact number of statements that get executed when running the following snippet of code if n = 5?

 int i = n; while(i > 0) { System.out.print("*"); i--; }

Were learning big-oh notation, and i'm not understanding why this statement does not run 5 times.

please help thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!