The following procedure is intended to return the number of times the value val appears in the list nylist. The procedure does not work as intended, Line 1: PROCEDURE countNumoccurences (mylist, val) Line 2: Line 3: FOR EACH item IN mylist Line 4: Line 5: count = 0 Line 6: IF(item = val) Line 7: tine 8: count count + 1 tine 9: Line 10: Eine 11: RETURN (count) 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)
C. 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 ->

Answers

Answer 1

Answer:

C. Moving the statement in line 5 so that it appears between lines 2 and 3

Explanation:

Given

The attached procedure

Required

What should be modified

The problem in the procedure is on line 5

i.e. count = 0

This line is within the loop, and this means that the count variable is initialized to 0 each time the loop is repeated.

To solve this, the count variable has to be removed from the loop to somewhere before the loop.

Hence, option (c) is correct

Answer 2

Throughout our procedure, even though we proclaimed count = 0 inside the for loop, the count has been valued at 0.  

After that, When a certain value is found equal to Val, the count has been incremented by 1. The count is set to 0 again in the next iteration, so at the end, if we found an element equivalent to Val 1, its real count has been returned.To get around this, we'll define count outside of the for loop to acquire the true count of instances of that specific value.

Therefore, the answer is "Option C".

Learn more:

brainly.com/question/14941418


Related Questions

Use at Least one hundred words to explain what you did the last time your handheld personal computer went slow.​

Answers

Answer:

Disk defragmentation

clear up storage

restart the computer

Explanation:

PC's going slow is a very common occurence nowadays and what i had to do to usually fix slow computers is to first use disk defragmentation which will automatically sort our files and put them in the right order.Second is to delete any unnessary files,folders,programs that i no longer use or its just sitting there eating dust and finally my last resort is to restart the pc which usually helps fix most of the issues including slow PCs which might be caused by some errors during startup.

Hope this helped

Programming errors can result in a number of different conditions. Choose all that apply.
The program will halt execution.
An error message will be displayed.
Incorrect results will occur.
Code will run faster.
the first 3

Answers

Answer:

The program will halt execution and and error message will be displayed. Probably number 3 too.

Answer:

A, B and C

Explanation:

NEED HELP IMMEDIATELY!!
What is the difference between a worm and a typical virus?
A) Worms are a type of spyware; viruses are a type of malware.
B) Worms are impossible to remove; viruses can be tracked and removed.
C) Worms are stronger than viruses; viruses are stronger than spam.
D) Worms travel independently of human action; viruses require human actions.

Answers

Answer:

Option C

Explanation:

Option A is incorrect as Worm is a form of malware

Option B is incorrect because antivirus can remove all forms of malware

Option C is correct because a worm is more problematic as compared to the virus. Also, viruses are weaker than worm because they need a host file to run but a worm can work independently.

Option D is also incorrect because both are able to self replicate.

Other Questions
Please help I need help with #17, 19, and 21 Why did Islam split into the two main factions?A. They didn't agree about whether or not to make images of Allah and Muhammad. B. They didn't agree about whether or not to make images of Allah and MuhammadC . They didn't agree on how to pray. Government is a trustee. Argue for and against. How was the Thirteenth Amendment different from the Emancipation Proclamation?AThe Thirteenth Amendment legally ended slavery throughout the US, while the Emancipation freed slaves from Confederate states.BThe Thirteenth Amendment provided legal protections to those who were freed by the Emancipation Proclamation.CThe Thirteenth Amendment freed slaves from Confederate states, while the Emancipation legally ended slavery throughout the US.DThe Thirteenth Amendment was issued by President Lincoln, while the Emancipation Proclamation was passed by Congress.How was the Thirteenth Amendment different from the Emancipation Proclamation?AThe Thirteenth Amendment legally ended slavery throughout the US, while the Emancipation freed slaves from Confederate states.BThe Thirteenth Amendment provided legal protections to those who were freed by the Emancipation Proclamation.CThe Thirteenth Amendment freed slaves from Confederate states, while the Emancipation legally ended slavery throughout the US.DThe Thirteenth Amendment was issued by President Lincoln, while the Emancipation Proclamation was passed by Congress. Please help. I'm having trouble with these.1.) Identify the Precedents Set by President Washington's Administration Using the quotation below and other sources, write a paragraph identifying the precedents that George Washington's administration set for future presidential administrations. Consider how Washington organized his government and the important events that took place under his administration. Explain why the first presidential administration was so important for the future course of American government, and why the United States was fortunate in having such a unifying figure as George Washington as its first President.There is scarcely any part of my conduct which may not hereafter be drawn into precedent.President George Washington2.) Explain the Importance of the Louisiana Purchase Write a paragraph explaining the events leading to the 1803 Louisiana Purchase and why the purchase was significant. Describe the events leading up to the purchase, including the political changes in the Americas that influenced Napoleon's decision to sell the territory. Explain the extent of the purchase and why the Louisiana Territory was important to the economic interests of the United States. Consider how Jefferson's decision to buy the Louisiana Territory was determined by his vision of the future of the United States and the kind of country he hoped would develop. Explain why he felt that he had overstepped his authority as President in purchasing the territory. What word BEST describes the tone of the following sentence?"These books offer a safety net, a place where kids 'flirt with those questions without getting into trouble."" A Reassuring B. Destructive C. Jubilant D. Discouraging Railroad tracks made of 1025 steel are to be laid during the time of year when the temperature averages 4C (40F). Of a joint space of 5.4 mm (0.210 in.) is allowed between standard rails of length 11.9 m (39 ft), what is the highest possible temperature that can be tolerated without the introduction of thermal stresses 1. The Pobble who has no toes Had once as many as we; When they said, "Some day you may lose them all;" He replied, "Fish fiddle de-dee!" And his Aunt Jobiska made him drink Lavender water tinged with pink For she said, "The World in general knows There's nothing so good for a Pobble's toes!" (from "The Pobble Who Has No Toes" by Edward Lear) Which rhyme scheme does this poem follow? 01. a babcdcd 2. abbacddc 3. abcbd da a 4. abcba a bb HELP ME PLEASEEEEEEEEEEEEEE Animal house rescue is holding a fundraiser raffle. they sell 2,980 tickets for $1 each for a prize telescope valued at $425. what is the expected gain or loss to a participant purchasing ten ticketsA)$4,240.00 gainB)$8.57 lossC)$0.86 lossD)$12.85 gain What is the allusion in the following lines referencing?FREDERICK. But where is Bruno, our elected Pope, That on a Fury's back came post from Rome? Will not his grace consort the Emperor?A. A horse ridden furiouslyB. the Erinyes, goddesses of vengeanceC. A winged, fire dragonD. A creature fought by Perseus 4x-2(x-5)=-8+4x+12 answer plz help #lovedafans Determine side x. Round to the nearest unit. 20 9 12 5 There are 1,024 players in a tennis tournament. In each round, half the players are eliminated. Which function can be used to find the number of players remaining in the tournament at the end of x rounds? PLEASE HELPI DONT UNDERSTAND HELP HELP HELPPPPPPP Dahin sa Tayo ay binubuhay Ng kalikasan, ano Ang ating tungkulin at pananagutan dito? pangatwiran. A low-cost noncontact temperature measuring tool may be able to identify railroad car wheels that are in need of repair long before a costly structural failure occurs. If the BNF railroad saves $63,723 in year 1, and starting year 2, the amounts increasing by $14,768 each year for 5 years, what is the present worth of the savings in year 0 at an interest rate of 10% per year pay:11.71 per hourhours:11 hours per week The Fine Crate Company owns several machines which cut wooden planks for building storage pallets, automatically loading the planks into rolling bins for transportation and handling. Each bin holds 200 planks and a machine can cut and load one bin in an hour, which Fine Crate Company uses planks at a rate of 1000 planks an hour. If the Fine Crate Company were to use a kanban loop to control the filling of the rolling bins, attaching one kanban card to each bin, how many cards should be used to govern this production, assuming a policy variable (safety factor) of 20%? a. 15 b.6 c. 32 d.11 e. 8