Question: 4. (15 points) Design and analyze an O(n)-time algorithm that takes as input a lengthn array of integers and an integer k in {1,,n}, and
4. (15 points) Design and analyze an O(n)-time algorithm that takes as input a lengthn array of integers and an integer k in {1,,n}, and either computes a smallest contiguous subarray A of A such that every integer in the set {0,,k1} occurs at least once in A, or reports (correctly) that no such subarray A exists
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
