Question: Consider the two algorithms below. Algorithm I Algorithm II count 0 total 0 FOR EACH element IN numberList { total total + element count count

Consider the two algorithms below.
Algorithm I Algorithm II
count 0
total 0
FOR EACH element IN numberList
{
total total + element
count count +1
avg total / count
}
DISPLAY(avg) count 0
total 0
FOR EACH element IN numberList
{
total total + element
count count +1
}
avg total / count
DISPLAY(avg)
Which of the following is true about the number of steps in the algorithms?
Algorithm I is more efficient than algorithm II.
Algorithm II is more efficient than algorithm I.
Algorithm I and algorithm II are equally efficient.
Algorithm II and algorithm I are both inefficient.

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!