Write a program to determine the length of bursts of zero\'s in a list of N numb
ID: 3597663 • Letter: W
Question
Write a program to determine the length of bursts of zero's in a list of N numbers stored in an array. The program should record the length of the bursts of zero's in another array. The program should then print the lengths of the bursts. Using this second array with the lengths of the bursts, it should also compute and print the following: the average length of the bursts, the minimum burst length, the maximum burst length, and the total number of zeros (the sum of the burst lengths). Your program should: Prompt the user for the size of the list (N). Then it should prompt the user to enter N numbers and store them into an array called list. Note, you should specify the maximum size of N allowed (based on how large you declare your array). Given N and list, your program should compute the lengths of the bursts of zeros and store them in an array called Burstlengths. After computing and storing the burst lengths you should terminate your Burstlengths array with a sentinel (-1). Use a for loop in this step. Given the Burstlengths array with a sentinel (-1), use a while loop to print the list of burst lengths. Format this nicely in a table with headings. Given the Burstlengths array with a sentinel (-1), compute and then print the following information: 1. 2. 3. 4. a. Average burst length b. Minimum burst length c. Maximum burst length d. Total number of zerosExplanation / Answer
The flowchart/Steps for the program are as follows:
1. Input the list of numbers
2. Traverse the elements of the list
3. If the element = 0 , start the burst count with 1
4. Continue increasing the burst count till 0 continues in the list
5. On encountering an element different from 0, stop the burst count and save
it in the array.
6.Repeat 4 and 5 every time a 0 is encountered in the list.
7.Once the busrt count array is ready.Process for minimum, maximum, average and
total count.
8. Initialize min and max as the first element of the burst array.Initialize totalcount as 0.
9.Traverse the burst array with updating min,max and totalcount based on the values of the array.
10.Output the mim,max, average as totalcount/(length of the burst array) and totalcount.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.