Page 1 of 1

Array A contains positive numbers that can be smaller than 1, larger than 1, or equal to 1. Find the sub-array A[i..j],

Posted: Thu May 05, 2022 1:01 pm
by answerhappygod
Array A Contains Positive Numbers That Can Be Smaller Than 1 Larger Than 1 Or Equal To 1 Find The Sub Array A I J 1
Array A Contains Positive Numbers That Can Be Smaller Than 1 Larger Than 1 Or Equal To 1 Find The Sub Array A I J 1 (25.44 KiB) Viewed 23 times
THE NUMBERS ARE ALL POSITIVE. DO NOT CHECK FOR NEGATIVE NUMBERS.
Please make sure a product of 2 numbers will be computed in O(1)
time and explain why it is correct.
Array A contains positive numbers that can be smaller than 1, larger than 1, or equal to 1. Find the sub-array A[i..j], such that the product of numbers in A[i..j] (i.e., A × A[i+1] x ... × A[j - 1] × A[j]) is maximized. Of course, you should describe the fastest algorithm that you can find. A product of two numbers can be computed in time O(1). Describe your algorithm in words, provide a pseudocode and briefly explain why your algo- rithm is correct.