Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.


+1 vote
asked Apr 26, 2022 by Paul Hill (290 points)

I am trying to create a simple implementation of the FlajoletMartin algorithm using Python. The stream will be the contents of a text file and you will produce an approximation of the number of unique words in the file as given by the algorithm. You will need to process the file one line at a time and may not store any part of the file. You can obtain words by splitting the lines on whitespace. Your code will be run from a terminal according to the following command

The text file is:


this is a fun file
this is the second line of the file
this is the third line of the file
this is the fourth and final line of the file

import sys

for line in sys.stdin:
words = line.split()
for word in words:
bin_string = bin(hash(word))

1 Answer

0 votes
answered Apr 26, 2022 by Peter Minarik (89,130 points)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.