124k views
1 vote
Can someone help me with this? Please I really need it! No links or I’ll just report you

Can someone help me with this? Please I really need it! No links or I’ll just report-example-1

1 Answer

7 votes

Answer:

(a) In line 3, 2 should be changed to 1

Step-by-step explanation:

Given

The attached procedure to return true if numberList is in ascending order

Required

Which line(s) need to be changed

On line 3 of the program, we have:;


count \to 2

On line 6, we have the following comparison:


numberList[count] <numberList[count-1]

Substitute 2 for count


numberList[2] <numberList[2-1]


numberList[2] <numberList[1]

The above implies that, the first comparison made by the program is to compare numberList elements at index 2 and index 1.

This means that, the first element (i.e. index 0) has been ommitted in the program.

Hence, for the program to work as intended, 2 should be changed to 1 on line 3

User Manuelkruisz
by
5.6k points