Question 9 The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Line 1: PROCEDURE countNumoccurences...


Question 9<br>The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended.<br>Line 1:<br>PROCEDURE countNumoccurences (myList, val)<br>{<br>FOR EACH item IN myList<br>{<br>count + 0<br>Line 2:<br>Line 3:<br>Line 4:<br>Line 5:<br>Line 6:<br>IF(item = val)<br>Line 7:<br>{<br>count + count + 1<br>Line 8:<br>Line 9:<br>}<br>}<br>RETURN (count)<br>Line 10:<br>Line 11:<br>Line 12: }<br>Which of the following changes can be made so that the procedure will work as intended?<br>A<br>Changing line 6 to IF(item<br>count)<br>B<br>Changing line 6 to IF(myList[item]<br>= val)<br>Moving the statement in line 5 so that it appears between lines 2 and 3<br>D<br>Moving the statement in line 11 so that it appears between lines 9 and 10<br>

Extracted text: Question 9 The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Line 1: PROCEDURE countNumoccurences (myList, val) { FOR EACH item IN myList { count + 0 Line 2: Line 3: Line 4: Line 5: Line 6: IF(item = val) Line 7: { count + count + 1 Line 8: Line 9: } } RETURN (count) Line 10: Line 11: Line 12: } Which of the following changes can be made so that the procedure will work as intended? A Changing line 6 to IF(item count) B Changing line 6 to IF(myList[item] = val) Moving the statement in line 5 so that it appears between lines 2 and 3 D Moving the statement in line 11 so that it appears between lines 9 and 10

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here