Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve question 1 and question 2 Dont provide prove where not required please i need solution in detail of these asap As part of
Please solve question 1 and question 2 Dont provide prove where not required please i need solution in detail of these asap
As part of an ongoing study, scientists in Iceland have been logging the noon temperature over the last n days. Let Til be the temperature on day i for i = 1,2, , n. Temperatures can be positive or negative. 1. Design an algorithm that finds, given a value of r, finds the set of r consecutive days with the maximum average temperature. Analyze the running time of your algorithm but no proof of correctness is required. The running time should not depend on r. 2. Consider the following algorithm that claims to determine whether there is a set of consecutive days whose average temperature is exactly 0 Step 1. Let Cl1| = T[1] and for i = 2, . . . , n, let C = T[i] + C[i-1] Step 2. Sort C by increasing value using MergeSort and let C' be the resulting array. Step 3. If there exists i such that C Ci+1, output "yes". Output 'no" otherwise (a) What is the running time of this algorithm? (b) Is the algorithm correct? Either provide an example where the algorithm returns the wrong answer or provide a brief proof of correctnessStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started