Starting from:
$30

$24

Lab 8 Bit Vectors and Bloom Filters Solution

Problem 2




Design and implement bit operations on an array of int values treated as a bit vector:




Let Arr be an integer array of size N (N is taken as input). We can treat this array as a bit vector by storing only 0s or 1s as its elements.



Set operation: This operation sets the jth element (1<=j<=N) of the given integer array Arr. (j is taken as input)



Get operation. This operation returns the jth element (1<=j<=N) of the given integer array Arr. (j is taken as input)



Implement the set and get operations on an array of integers, to be used as a bit vector. You can use the following table for designing your functions.




Key
Function
Input Format
Description


0
CreateBitVector
0 N
Creates a bit vector S in the form of an integer array of size N








taken as input; And then initializes all its elements to zero.


1
Set
1 j
Sets the value of jth element of S to 1.


2
Get
2 j
Returns the value of jth element of S. You must also print the








returned value.




Sample input and output
















Sample Input




Sample Output


0 100






1


1 23






1


1 62






0


1 91










2 62










2 91










2 34










-1









































































1 | P a g e

More products