Question: Given an array A of n integers in the range [0,k), we would like to build an index, which we would like to use to

Given an array A of n integers in the range [0,k), we would like to build an index, which we would like to use to answer any query of type "what is the number of integers in A that are in the range [a, b]? For this purpose, write the following two procedures: Procedure PREPROCESS(A) should process A to build an index in O(n + k) time. The size of your index should be o(k). Procedure QUERY(A, a, b) should return the number of integers in A that are in the range [a, b] in O(1) time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
