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),

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

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!