Question: Input are a sequence X = k1, k2, ... kn of real numbers (not necessarily in sorted order), an integer m, and a real number

 Input are a sequence X = k1, k2, ... kn of

Input are a sequence X = k1, k2, ... kn of real numbers (not necessarily in sorted order), an integer m, and a real number s. The problem is to check if there exists an i (where 1 s is (n-m +1)) such that ki +ki+1 +... +ki+m-1 =s. Present an O(n) time algorithm to solve this problem. Your running time must be O(n) even when m is a significant fraction of n. Use a specific instance as an example, if X = 8.5, 5.2, 3.4, 7.1, 11.5, 15.1, 9.3, 2.7, m = 3, and s = 22.0, then there exists such an i = 3 since 3.4+ 7.1+11.5 = 22.0. You need to show why your algorithm has run time O(n)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!