Bda Experiment 4: Roll No. A-52 Name: Janmejay Patil Class: BE-A Batch: A3 Date of Experiment: Date of Submission Grade
Bda Experiment 4: Roll No. A-52 Name: Janmejay Patil Class: BE-A Batch: A3 Date of Experiment: Date of Submission Grade
Bda Experiment 4: Roll No. A-52 Name: Janmejay Patil Class: BE-A Batch: A3 Date of Experiment: Date of Submission Grade
Designed to find the number 1’s in a data set. This algorithm uses O(log²N) bits to
represent a window of N bit, allows estimating the number of 1’s in the window with an
error of no more than 50%.
In the DGIM algorithm, each bit that arrives has a timestamp, for the position at which it
arrives. if the first bit has a timestamp 1, the second bit has a timestamp 2, and so on..
the positions are recognized with the window size N (the window sizes are usually taken
as a multiple of 2). The windows are divided into buckets consisting of 1’s and 0's.
➢ The right side of the bucket should always start with 1. (if it starts with a 0, it is to
be neglected) E.g. · 1001011 → a bucket of size 4, having four 1’s and starting
with 1 on its right end.
➢ Every bucket should have at least one 1, else no bucket can be formed.
➢ All buckets should be in powers of 2.
➢ The buckets cannot decrease in size as we move to the left. (move-in increasing
order towards left)
B.2. Input and Output:
bucket_list = []
bucket_size_count = {}
def checker():
for ct in bucket_size_count.keys():
if bucket_size_count[ct] > 2:
bucket_size_count[ct] -= 2
start_index = 0
end_index = 0
pair = 0
for i in range(len(inp)):
bit = inp[i]
if bit == 1:
if pair == 1:
end_index = i
pair = 0
if 2 in bucket_size_count:
bucket_size_count[2] += 1
else:
bucket_size_count[2] = 1
checker()
else:
start_index = i
pair = 1
print(bucket_list)
starts = []
ends = []
starts.append(s)
ends.append(e)
for i in range(len(inp)):
bit = inp[i]
if i in starts:
elif i in ends:
else:
k = int(input("\nEnter k : "))
length = len(inp)
bound1 = length - 1 - k
bound2 = length - 1
ones_count = 0
break
ones_count += int(size / 2)
ones_count += size
OUTPUT
B.3. Observations and learning:
Advantages
Drawbacks
➢ As long as the 1s are fairly evenly distributed, the error due to the unknown region
is small – no more than 50%.
➢ But it could be that all the 1s are in the unknown area at the end. In that case, the
error is unbounded.
B.4. Conclusion: