diff --git a/pydatastructs/huffman/Analysis.py b/pydatastructs/huffman/Analysis.py new file mode 100644 index 000000000..c33f3a4ca --- /dev/null +++ b/pydatastructs/huffman/Analysis.py @@ -0,0 +1,97 @@ +import random + + +def rand_codeword(n): # function to generate a random n length codeword + + word = "" + for i in range(n): + # give 0 or 1 as the ith bit in the codeword + temp = str(random.randint(0, 1)) + word += temp + return word # n length codeword + + +def BSC(x, p): # simulate the output of BSC channel + y = "" + for i in range(len(x)): + # generate a float b/w 0 and 1; if it is <= P(bitflip) then bitflip occurs + check = random.random() + if check <= p: + if x[i] == "1": # bitflip + y += "0" + else: + y += "1" + else: + y += x[i] # no bitflip + return y + + +# Driver code starts here + +f = open("Results.txt", 'w') + +for i in range(6): + # parameters + N = 2000 + + n = int(input("n = ")) + f.write("n = ") + f.write(str(n)) + f.write("\n") + k = int(input("k = ")) + f.write("k = ") + f.write(str(k)) + f.write("\n") + p = float(input("p = ")) + f.write("p = ") + f.write(str(p)) + f.write("\n") + + codeword_list = set() # set to store 2^k random codewords + # set ensures that there is no duplication + while len(codeword_list) < pow(2, k): + word = rand_codeword(n) + # generate 2^k random n length codewords and store them in the set + codeword_list.add(word) + + Len = len(codeword_list) # cardinality of code C = 2^k + pOfEmin = 1 + for c in range (5): + E = 0 + for i in range(N): + # pick a random codeword from the set as input to BSC + ip = random.choice(tuple(codeword_list)) + y = BSC(ip, p) # y is output of BSC + + j = 0 + min = n # variable to track minimun Hamming distance + word = "" # codeword with minimum Hamming distance + for j in codeword_list: + dist = 0 # initialising distance to be 0 + for k in range(n): + if y[k] != j[k]: + dist += 1 # incrementing distance when flipped bit is found + if dist < min: # updating min Hamming distance and estimate + min = dist + # word is the estimate; if it is not equal to the input, then E is incremented + word = j + if word != ip: + E += 1 + + # No. of decoding errors + f.write("E = ") + f.write(str(E)) + f.write("\n") + + # P(error) for a random code C and BSC with parameters (n, k, p) + pOfE = E/N + if pOfE < pOfEmin: + pOfEmin = pOfE + + f.write("P(Error) = ") + f.write(str(pOfE)) + f.write("\n") + + f.write("Minimum P(Error) = ") + f.write(str(pOfEmin)) + f.write("\n\n") diff --git a/pydatastructs/huffman/Decoded1.txt b/pydatastructs/huffman/Decoded1.txt new file mode 100644 index 000000000..d5b401228 --- /dev/null +++ b/pydatastructs/huffman/Decoded1.txt @@ -0,0 +1,7 @@ +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane \ No newline at end of file diff --git a/pydatastructs/huffman/Decoded2.txt b/pydatastructs/huffman/Decoded2.txt new file mode 100644 index 000000000..eec54f288 --- /dev/null +++ b/pydatastructs/huffman/Decoded2.txt @@ -0,0 +1 @@ +do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at \ No newline at end of file diff --git a/pydatastructs/huffman/Decoded3.txt b/pydatastructs/huffman/Decoded3.txt new file mode 100644 index 000000000..18528eabf --- /dev/null +++ b/pydatastructs/huffman/Decoded3.txt @@ -0,0 +1,88 @@ +Friends, Romans, countrymen, lend me your ears; +I come to bury Caesar, not to praise him. +The evil that men do lives after them; +The good is oft interred with their bones; +So let it be with Caesar. The noble Brutus +Hath told you Caesar was ambitious: +If it were so, it was a grievous fault, +And grievously hath Caesar answer’d it. +Here, under leave of Brutus and the rest– +For Brutus is an honourable man; +So are they all, all honourable men– +Come I to speak in Caesar’s funeral. +He was my friend, faithful and just to me: +But Brutus says he was ambitious; +And Brutus is an honourable man. +He hath brought many captives home to Rome +Whose ransoms did the general coffers fill: +Did this in Caesar seem ambitious? +When that the poor have cried, Caesar hath wept: +Ambition should be made of sterner stuff: +Yet Brutus says he was ambitious; +And Brutus is an honourable man. +You all did see that on the Lupercal +I thrice presented him a kingly crown, +Which he did thrice refuse: was this ambition? +Yet Brutus says he was ambitious; +And, sure, he is an honourable man. +I speak not to disprove what Brutus spoke, +But here I am to speak what I do know. +You all did love him once, not without cause: +What cause withholds you then, to mourn for him? +O judgment! thou art fled to brutish beasts, +And men have lost their reason. Bear with me; +My heart is in the coffin there with Caesar, +And I must pause till it come back to me. +Oh me! Oh life! of the questions of these recurring, +Of the endless trains of the faithless, of cities fill’d with the foolish, +Of myself forever reproaching myself, (for who more foolish than I, and who more faithless?) +Of eyes that vainly crave the light, of the objects mean, of the struggle ever renew’d, +Of the poor results of all, of the plodding and sordid crowds I see around me, +Of the empty and useless years of the rest, with the rest me intertwined, +The question, O me! so sad, recurring—What good amid these, O me, O life? +Answer. +That you are here—that life exists and identity, +That the powerful play goes on, and you may contribute a verse. +I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation. +Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon of hope to millions of slaves, who had been seared in the flames of whithering injustice. It came as a joyous daybreak to end the long night of their captivity. But one hundred years later, the colored America is still not free. One hundred years later, the life of the colored American is still sadly crippled by the manacle of segregation and the chains of discrimination. +One hundred years later, the colored American lives on a lonely island of poverty in the midst of a vast ocean of material prosperity. One hundred years later, the colored American is still languishing in the corners of American society and finds himself an exile in his own land So we have come here today to dramatize a shameful condition. +In a sense we have come to our Nation’s Capital to cash a check. When the architects of our great republic wrote the magnificent words of the Constitution and the Declaration of Independence, they were signing a promissory note to which every American was to fall heir. +This note was a promise that all men, yes, black men as well as white men, would be guaranteed the inalienable rights of life liberty and the pursuit of happiness. +It is obvious today that America has defaulted on this promissory note insofar as her citizens of color are concerned. Instead of honoring this sacred obligation, America has given its colored people a bad check, a check that has come back marked “insufficient funds.” +But we refuse to believe that the bank of justice is bankrupt. We refuse to believe that there are insufficient funds in the great vaults of opportunity of this nation. So we have come to cash this check, a check that will give us upon demand the riches of freedom and security of justice. +We have also come to his hallowed spot to remind America of the fierce urgency of Now. This is not time to engage in the luxury of cooling off or to take the tranquilizing drug of gradualism. +Now is the time to make real the promise of democracy. +Now it the time to rise from the dark and desolate valley of segregation to the sunlit path of racial justice. +Now it the time to lift our nation from the quicksand of racial injustice to the solid rock of brotherhood. +Now is the time to make justice a reality to all of God’s children. +I would be fatal for the nation to overlook the urgency of the moment and to underestimate the determination of it’s colored citizens. This sweltering summer of the colored people’s legitimate discontent will not pass until there is an invigorating autumn of freedom and equality. Nineteen sixty-three is not an end but a beginning. Those who hope that the colored Americans needed to blow off steam and will now be content will have a rude awakening if the nation returns to business as usual. +There will be neither rest nor tranquility in America until the colored citizen is granted his citizenship rights. The whirlwinds of revolt will continue to shake the foundations of our nation until the bright day of justice emerges. +We can never be satisfied as long as our bodies, heavy with the fatigue of travel, cannot gain lodging in the motels of the highways and the hotels of the cities. +We cannot be satisfied as long as the colored person’s basic mobility is from a smaller ghetto to a larger one. +We can never be satisfied as long as our children are stripped of their selfhood and robbed of their dignity by signs stating “for white only.” +We cannot be satisfied as long as a colored person in Mississippi cannot vote and a colored person in New York believes he has nothing for which to vote. +No, no we are not satisfied and we will not be satisfied until justice rolls down like waters and righteousness like a mighty stream. +I am not unmindful that some of you have come here out of your trials and tribulations. Some of you have come from areas where your quest for freedom left you battered by storms of persecutions and staggered by the winds of police brutality. +You have been the veterans of creative suffering. Continue to work with the faith that unearned suffering is redemptive. +Go back to Mississippi, go back to Alabama, go back to South Carolina go back to Georgia, go back to Louisiana, go back to the slums and ghettos of our modern cities, knowing that somehow this situation can and will be changed. +Let us not wallow in the valley of despair. I say to you, my friends, we have the difficulties of today and tomorrow. +I still have a dream. It is a dream deeply rooted in the American dream. +I have a dream that one day this nation will rise up and live out the true meaning of its creed. We hold these truths to be self-evident that all men are created equal. +I have a dream that one day out in the red hills of Georgia the sons of former slaves and the sons of former slaveowners will be able to sit down together at the table of brotherhood. +I have a dream that one day even the state of Mississippi, a state sweltering with the heat of oppression, will be transformed into an oasis of freedom and justice. +I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin but by their character. +I have a dream today. +I have a dream that one day down in Alabama, with its vicious racists, with its governor having his lips dripping with the words of interposition and nullification; that one day right down in Alabama little black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers. +I have a dream today. +I have a dream that one day every valley shall be engulfed, every hill shall be exalted and every mountain shall be made low, the rough places will be made plains and the crooked places will be made straight and the glory of the Lord shall be revealed and all flesh shall see it together. +This is our hope. This is the faith that I will go back to the South with. With this faith we will be able to hew out of the mountain of despair a stone of hope. +With this faith we will be able to transform the jangling discords of our nation into a beautiful symphony of brotherhood. +With this faith we will be able to work together, to pray together, to struggle together, to go to jail together, to climb up for freedom together, knowing that we will be free one day. +This will be the day when all of God’s children will be able to sing with new meaning “My country ’tis of thee, sweet land of liberty, of thee I sing. Land where my father’s died, land of the Pilgrim’s pride, from every mountainside, let freedom ring! +And if America is to be a great nation, this must become true. So let freedom ring from the hilltops of New Hampshire. Let freedom ring from the mighty mountains of New York. +Let freedom ring from the heightening Alleghenies of Pennsylvania. +Let freedom ring from the snow-capped Rockies of Colorado. +Let freedom ring from the curvaceous slopes of California. +But not only that, let freedom, ring from Stone Mountain of Georgia. +Let freedom ring from every hill and molehill of Mississippi and every mountainside. +When we let freedom ring, when we let it ring from every tenement and every hamlet, from every state and every city, we will be able to speed up that day when all of God’s children, black men and white men, Jews and Gentiles, Protestants and Catholics, will be able to join hands and sing in the words of the old spiritual, “Free at last, free at last. Thank God Almighty, we are free at last.” \ No newline at end of file diff --git a/pydatastructs/huffman/Encoded1.txt b/pydatastructs/huffman/Encoded1.txt new file mode 100644 index 000000000..7fccde05f --- /dev/null +++ b/pydatastructs/huffman/Encoded1.txt @@ -0,0 +1 @@ +001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100010001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000110110011110101101111100100011000100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100011011001111010110111110010001100010001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000110001101100111101011011111001000 \ No newline at end of file diff --git a/pydatastructs/huffman/Encoded2.txt b/pydatastructs/huffman/Encoded2.txt new file mode 100644 index 000000000..2f77e62b4 --- /dev/null +++ b/pydatastructs/huffman/Encoded2.txt @@ -0,0 +1 @@ +000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111010001111001100111101111011011111001101111001001111110100110001000010011111111001111100111101111101101111101110000101100100001011001111110111101010000010111011011110001001010011111010101110100000101101010010101110000100101110110010001011000011011010101110001110111110110001101010011100010111000111100010010100011101100010011000011011011110001100001101101111000111011011110100001001001011111011111001111000100011000100000100110110111100010010111110011110001101000000101100111111011111001111101010111011001101100011100000010111000100100011001001011101111101000111100110011110111101101111100110111100100111111010011000100001001111111100111110011110111110110111110111000010110010000101100111111011110101000001011101101111000100101001111101010111010000010110101001010111000010010111011001000101100001101101010111000111011111011000110101001110001011100011110001001010001110110001001100001101101111000110000110110111100011101101111010000100100101111101111100111100010001100010000010011011011110001001011111001111000110100000010110011111101111100111110101011101100110110001110000001011100010010001100100101110111110100011110011001111011110110111110011011110010011111101001100010000100111111110011111001111011111011011111011100001011001000010110011111101111010100000101110110111100010010100111110101011101000001011010100101011100001001011101100100010110000110110101011100011101111101100011010100111000101110001111000100101000111011000100110000110110111100011000011011011110001110110111101000010010010111110111110011110001000110001000001001101101111000100101111100111100011010000001011001111110111110011111010101110110011011000111000000101110001001000110010010111011111 \ No newline at end of file diff --git a/pydatastructs/huffman/Encoded3.txt b/pydatastructs/huffman/Encoded3.txt new file mode 100644 index 000000000..15696085b --- /dev/null +++ b/pydatastructs/huffman/Encoded3.txt @@ -0,0 +1 @@ +10010000110000001110010101011010100100111111110010011111110101101111000010101001001111111110010101011011001011011000001100011011100101011001111111110000010101011011111101110011110110001010110110000011100110000000010010010010101001110000110111111100101010110111001111101110101110001111101100000011000111100100000100000101001000000010011111110101101010111111011101011111001100000100001110100001111110100111110111100110010011101001000101101000111100110011010111110001111011110101000101111111011100101011110110110101111100001111001101001010011110000001010110010000111101111010001110111100100101010011101001000101101000111101100110101010011011110111010011110100001010111110111010110110010000000000101101111100101011110111101011110111101000101110000111000111101001010010100100100101010011101001001011101011111000001101111101111011111000111001111100101011110111101011110010000010000010100100000001001100111100100010110100011110101101000011111000001111000110100000011011010111101100100100111010010010011100010111101011110111010110000110111101100010101101101111001000001000001010010000000111100101100001001111000110111000111011110110111101011011001000001100110100111000011011000101110111101111110010100100000011110100101010011111110111101111110010110000100111100011101100100000111001100110110101101100100111000101000110110110001011100111110011100001100001010110111101100100000111001100110110101101100100110000110001111101010001011110101111001000001000001010010000000111100001010100100101001000011001110110110111101111011100110010011101001001001100100000011001111111110110010101101001000011111000001100010011010011111010000101110001101000000110110101111011001001111000010101101111101111010001111000000101001011100100100100100111010010000110101000001110001101000000110110101111011001001110111010011110000101111110101010010110101101100000100000011111000001111110111100001011001001010100111010010010111010111100000000011111011110100010110001111000110001100010011111111000110001100011111010101001011010110110000010000001111100000111111011100101011001001001001001110100100000101011011100111100011011111101110101110100110011000110001100111111101110101111100100000100000101001000000011001110110100111000101101100101001000010001100010011001001110100100100110011111001011000010011111011101100011100010000001110010101011011001111111000101000011110111101000010110110110001111000010101101111100100110110110010010111111011101011111011100100011001101001110000110100110110101111100011010000001101101011110110010011101001000011000010011111010001111100101100001001111000110111000111011110110111101011011001001001001010100111000011000010101101111000110100000011011010111101100100111011101001111000010111111010101001011010110110000010000001111100000111111011110000101100110010011101001001001100111111010100010111101011100011100001010110110011001110101011111110111100001010110001111100101000110011010110111100110100101001111101010101101110011111011101011110010011111110101101110011001110100100011110101010010000111100001000010101001010110111010011101101011101101111101111010001111011001001010100100001000110001111100101010000100001000100000100111000100111110001100000011001101001110100100100101011101101111101111010011101001110111010111110010000010000010100100000001110100001001110111111100011011100011101111011011110101101100100110011100001001110100100011110100010101111101111010100010111111011110100011111100110101010100000111110101000100110100111111001000000111001011011001111111100100000100000101001000000011111010100010111101011110010100111001101011000110011010011100001100011011100011101111011011110100101111010011010101011011011000011011110001110011111101111000011010011111010000101110100101100100000101001000011101001011110110000100001000011001101001110000110011100110111110001101000000110110101111011001001110100100001100001001111101000111110010110000100111100011011100011101111011011110101101100100100100101010011100001100001010110111100011010000001101101011110110010011101110100111100001011111101010100101101011011000001000000111110000011111101111000010110011001001110000110011110101101101111000110001100011101101011101101111010000100111110111101010001011111101001011111011110100011111001001110110110110011000100001100101000110001001110000110111111011110100000011111001000111111001100000001010000101011011001011011111101001111101111111000111110011110111010101100111000011000111110010000010101001010101100111110011101001000111101001111100101101011111010001111011010111011011111011110100000011111001000111100000010001011011001000010001100110111100101100001001111011110100111010011110001101110001110111101101111010010111001110000100111000011001110011011111000110100000011011010111101100100111010010000110000100111110100011111001011000010011110001101110001110111101101111010110110010010010010101001110000110000101011011001111111010011011000000011001111111110100011110111010011110000101111110101010010110101101100000100000011111000001111110111100001011001100100111000011011111010011001100011000110011111110101101010111111011101011101101011101001100110000010101001101001111100101110101000101111100011010000001101101011110110010011101001100110101011001111001100111110011100001101001101101011111110100010000001111000110111111000110111111101110101110100110011000110001100111111110010111010100010111110001101111101101101011111001111010110101001011001100100111000011001111010110110111100011000110001110110101110110111111000101010011010011111101001111101111111010010111001000110011111110101101010111111001010111101111010101011011010111111100101000110110010000100011001101001110100100011110101000101111111001010001101100100001111100101011110111101011010101011000011010100111011000101011011011110111101000101011001111111101110101111101111010110110000001011110001010100000111110100111110111110011100001001110000110010111100100110110110011010110011101110010101101111001110001111101111010101011011011110000000101111100010110000010110111110111010111000111000011011010110111010011010111000111001100001001011010010011111001110000110000101011011111101110010101111110101000100110100111111000101001001011111101111010001011100001110000001100001001010010110011001110001101000011000000011110010101111011110101111101110011001001010100111000011010100110001111101000110000000101111101110100111011101011111011110100011111100101010000100001001110101111101111010001000000111110010101111011110101111001000001000001010010000000100111110011100001100001010110111100011011111110111110110010010111111100110100011011001000011111011011111000110001110111101111111001010101101110011110001111000110010110011111111011101011111011100110011001001110000110010110101111101110011100111000111100011001011010111110000111000100011100111000111110100001011110111101000111100011010111101100010100101101111010010101001111010000101111011110100010100001111000000111001011011000000000011101010110011001111100111000011001000010111101111010001111001010101101110000010100010011110110000100001110101010011110100001011110111101000111100010100001111011110101100000101000100100111111110100001011111001001111011011100101001110001001111100011000110011101101101111100101011110111101011110111101000111100010101010101100001110100110101001111100111000011001000010111110111011000010000111000000101110001010100000001100110100100001110000001110011000001010100011001011010011101010110011111101110110000100001110000001010011111111001001111100000101010000011110010111010101011111011110100000001111000101010101011000011101001101011110111101010000101111000110111001111111100001010110111110010111010101011111011110100000001111000101000011110111101011000001010001001100111000010010011111011001110000110010000101110010110000010100111101111010100010111111001101100001110101110000110001111100100000100010011010011111011110100011111100001110110011101010111001111111101000010111101111010001111101000011110010011000111001010110100111110111001100001011001111111101000010111101111010001111010010110000110110011001011001110000011110011001101001000011100000010101001100101110011101101101100111110011100001100100001011110111101000111111001101010101000001110000001010011011011000101101001111010000101111000110001100010011111111010000101111011110100011111100110110001010011010110101110101011001111100001010110111101001010000001101011101101111110010000010101001010110101001110001101111101000010011111000000010101101100101011011111101110011001111100111000011001000010111101111010001111001110111110011010110110001111000010101101111110110010000111000001010001001110110000011000000001001111010000101111011110100011110000001010010111001111111100101011110111101011110111101000111100000010100101111111011100111101110101101100100001011100101011101010010110110011111001110100100010110100011110001101011110110001010010110111101001011001111111000110010111110111001110011100011110100101011101001000011011001111111000000111001011011000000000011101010110011001000010101001000111101010001011111011001101010100110111110001101110111011011111011110100010100001100111111100011001011111011100110011111110001100101111100001110001000111001110000100111000011000010101001001010010000100110010011101001000101101010001011111011000101011011011110000000001111110100010000001100100001010101111010100010111111100001110001000111100110010011110011101001011010011110000101011011110111011010010101101101111011011000100111110011101001000101101010001011111101111010001111110011010101001010010000000101101101100011111001101100010000110001110110011010001010011110100101100111111110000101011011110110001010110110111110111100001100011111001010100101101100000111000111110110101100111110001111001101001000001000011001100100111000011011111100011011111111010100011001101100110011000111101110101111001001101010011101011111001010111101111010111011000101011011011110111010011011000011000111011101011111001011101010001011111100101011111000110001110110011010111011011010100101010111101110101111110100111010010111010000001100011110000100111101111010001111011001000000110001011001010010111110110100111011110100101010010110000100010110111101001011110001010100000111000100000001001011011010110111111011101011111011110100011111101001110100101110100000011000111101000010111101011011000001110101100010110111101001011001100100111010010000110011110011010011110100110010101000000011110110000011000000001001111000011001101010011111111000111011001000000110001011111000110001101110010000011111001010000101100111111101110101111100101110101010010000111101000110001101110001111010110000111110010111010011010100001101101010010111110010100111101001011100001010110111110111010011011000011000100111111101000111011001010100101101111101111010001111100100001011011011110000101110010011111001101000101101111010010111110010000111000010101100101100010001101111000101101111010010110011001111001000101101001110100111110111101011011100101011011101011011001001110110100111001000000010011111100101000110111001111100001001111000111011001000000110001011111000111001100011001010100101111101000010111110101010110011000111110111010111110111011111000110000111101001010100111101000010111010011000100010011010010100100111111110010111010101011111010100001101111000111001001010111101000011000000000101101111011101011111011110100011110001011000100011011100101001111010000101111001011101001111011110100010000011101010110011110111010110010011011011001001011011111001000110011001110001101110111111100101000110111001111100001001111000111100100110101001100010101101100100111011011000011000000111000000110001100111111110111010111001010101101111101111010001111110001010010101100111101010111011001110101011111101000010111101111010001011100001111100101000110011010110111100110101111011011000100110011100011010011011010111111010010100111111010110110010101101000000101101111011000001100000000100111110001000101100100001001111111101111010001111110010101011000101000000010110111100011000110111001000001111100101000111011101001110100101101111100011000111010110101011111000100000001001100110011100011001001010011111101011011001010110100000010110111101100000110000000010011111000100010110010000100111111110111101000111111000011100010001111101000010111101111010001111110010101011000101000000010110111100011000110111001000001111100101000010111101110100111010010110111110001100011101001000011011100001100011111001000000111110011011001101100000101101111000111011000111101111010001111110111100001011000110010110000011111010000101110100001011001000000101100110001011011110100101111100001010110111110111101000111111001011010100001110101010011110100001011101101011101001100100000011111011101110101100010110111101001011001100100111000011001001010011111101011011001010110100000010110111101100000110000000010011111000100010110010000100111111110111101000111111001010101100010100000001011011110001100011011100100000111110010100001011111100001111001101001010011110100101111100011111000101001010011100001100011101110100110001000010101101111101000010111110011010101001101001000010110110001110111010111110111101000111111011101110110101001011111101000010111100011110011011000010010111111010110010001100001011111010000101111101111000101100100000111100011000111110011000001010010011001100010000011110110110001001100111000110010010100111111010110110010101101000000101101111011000001100000000100111110001000101100100001001111111101111010001111110010101011000101000000010110111100011000110111001000001111100101000010111101110100111010010110111110001100011111000100001010110011101100111010011010011101010110011110111010111110111101000111111001010100000010100100000100111101000010111000110001101110010000011111001010000101111010010101100100111001101101100011110000101011011110001001110101011010100111110100111110111010000111000000101111000010111100110010011110011111000001111011101011111101001110100111101010010101011111100010000101011011111001001011101011110010100111111010100010011010011111100101010110111001111110100010000001111101110100110110000110001111011101011101101000010001101111000101101111100111010000111110001110100110101000110111001000101101101100011111001010100101011010111101101111010010110011001001110000110110101111100011101000010101010000111110010100111111010100010011010011111100101010110111001111101110101111010110110000011111001110011000101101111010010111001110110100111100100000100011001100111101110001100011110111010111110010100001001101011110001111100101101000111001011001111100110011110010001111010001010111110111101000111110000000110010110100111101100111001010110100111101000010111101011011000001110110010000001100010111110000001110011011011000011111000011111001011110010100001010101100111110111101000111111011110000110010101011100010011111001000101011011111100101101000000110101001111010000101111011110100011111001000001010010101001011011110111101101011011110100101111100001010110111110111101000111110010010010100111001011000100000001000101101111010010111110100001011100011011010101101001110011000101010110100101011100100011001111111101111010001011000111100101001000000111101000111011001010101110101011001111100011111001100000101011011101110100010010100000011000111010110101011001111101110101111001011101001111100101101011100110011010010000011000111000110001101110010000011111001010000101111100101100001001111011101011100010100011000110001111101000101110000100110010011101001000101101001110100111010110101011001111100101100001001111000111110011000001010110111011101000011111011110101000101111110001100011000111110111001010110011111110110000010100100111111100011111000100011001011001111111110111001010111110000100111100101001110001100011110000100111100101110100111101100111111011100101011001111111100101101011011011000011011110001110011110110011101101000000010000101101100100101101111101111010001111011101011000110000111001010110000001111100000111100000111011001110101011010011110100001011111000011100010001111110000111000111001000010110110001111000010101101111101111010001111110011011011000000100110110011110111111010000101111101010001100110110011001110101001010001001001100100111000011011101111101110100111101000011110011010111101011011001001111011101001101100001100011110111101010001011111000110001101110010000011111001010001111101010000100111011010010001010001101101100010110010110111110100101111101111010011101001111100110000010101101110111010001001010000001100011101011010101100111101110101010010100001010000000111100001001111101000100001111100100111101101111100111010000101010100111101000010111110010101011000101000001111000000000111111001010100101110010001000001010010110110011001110001101101010100101100110000110111110100001011111010101001011010000001110101011001111101111010011101001110100100011001000000010110111110100001111100001110110011000101101111010010110011111110001100011011100100000111110010100011111010100001001110110010111100110100101011110111101101001111100101010110001010000000101101111110011000110101100110110000011111000111000111100001101111110010110100011100101100111110011111111000111110010110100011100101100111111110111101010001011111110101000010011111001010101101110011110001111000110010110011111111101111000000011001111001011011111001000010001110101010011011000010000100111110010011100101011011111000101101100101011010100100110011001110101010011100001101001101101011111100101001111000000100010110110010000111110111010111000111001110000111001100110100111110111101010001011111101111010001111000111100001011100111111110100001011110010011011011001001011011111001000111101110100111000111100001011100111100001101101100110101110011001111001000110011110000001000101101100100001111101110101110001110011100001110011001101001111101111010100010111111011110100010000001111100000000011110111010101001101100001000010011111001001110010101101111100010110110010101101010011101110101111101111010001111011001000000110001011111100110110001101101100010110100111101000010111101011001101100110101000001011110110010101111011011000111101000010111101111010011101001110101100010110111101001011001100111100100101110101111001010011111101010001001101001111110010101011011100111110111010111110010100001001101011110111101001110100111110010110100011100101100111110011111111000111110010110100011100101100111111110111101010001011111100101011111000110001110110010111100110100111111011001001111101101100110101001011110110100111011110000101011011111011110100011110000011111001011010001010011110100001011100010000000100101101101011011111110000101011011110100001110010110110000001111011011000111101000010111100100110110110010010110111110010001100110010011101001000110011111101010001001101001111100011000010010101111100101010110111001111101110101111101001110100111110101000110001100010101001010010110111101001100110101010111111011101011100000011101110111010101101111000110001101110010000011111001010001111010000101111011110100011110001001110010000110010001111110110000001100100101011100100110001111010000101111100111001101010010110011001111001000101101001110100111011101001110101101010111111011011111011100111110111010111001010101100110000110010011110111010111110111101000111111000110110100100111101101100000011000111101000010111110010101010101100001110101011001111101000010000101111010000011110111010111101110001100111100111110111101000111110110000100001010001101011110110011111000011111001110100011101010110011110110100001101100110011111010000101110110010000100001101110110100011000011101001101111001100100111011001110011010100101111011101001111011110100011111011011111011100111110111010111110111100011001111001111000000110001100011110111101000111111001100000101011011101110100001111101000010111011010011101111010110010000010001100100110001001100100111011001110011010100101111011110111111011110100011111011011111011100111110111010111000001110100001111000100000101011011111110111101000111101101100000001100111111110000101011011110110100101001010110001000101100111110011011000110001100000101100011110100001011101000010110010000001011001100010110111101001011111011101011110111101000111101001101100101110000111101111111001101000101111010111101000010111000010001100100111100011000111100100110110110010010110111110010001100110010011101100111001101010010111101111011111101111010001111101101111101110011111011101011111000011100010101111110101101100000111010110001011011110100101111000100000101011011111110111101000111100011010111101100111110010110011110100100001010110111110100001011100001000110010011110001100011101110101100100110110110010010110111110010001111101110101111011110100011110100101011000011101101111000010101100101100111111110100001011100011100001010101111010001000011010101010100110110011001001110110011100110101001011110111010011110111101000111110110111110111001111101110101111101111000110011110011111001001101101100100101101111100100011111000111000000110001100001111011011000111101110101111000110001100011110100001011110010010001010011011100111011010011111001011010011111000011010000001010110011001001110000110111111001011010110110110000110111100011100111100010100010111000110001110001010100000111101111010001111010110001011011110100101111101110101111010100110100100001100010101010110011111111011110100011111101100000011001001010111001001100011110100001011110111101000111111011110101101110010101101111110000101011011111011101011111011001010110100100000010100101101111101111000101100111110111101000111101101001101100100001101110111010110001011011110100101111101000010111011110111100111011010011111001010101100010100000001011011111100100111101101111100111010000101010100100110011110010001011010011101001110100100101001110001011001000001110101011001111010011011011011111011100100001111010000101111011110100011111100101010110001010000000101101111110011000110101100110110000011100111011010011111000001011001011110110111110111100010110011110110101110100110010101001011011001010110111111001010111110001100011101011010101111111001101000010001001111101100101101101111100011110111101000100000011110111010011110000101111011101011001101011101100110100000100010110111010101100111110001101101011110110110111010111110100001011100010000000100101101101011011111110000101011011110010001101011110110100011000011110110110001001100111110011100101110101001101100100101011110100011110010011110101101100011001110101110111101000000010011110111010011101011010101111110000101111001010101101111000111110110101111110001110001110010110010111010101010111010101100110011001111001000101101010100100001111100101110101010111110101010110011000111110111101010001011111101111010001111110010101011000101000000010110111100011000110111001000001111100101000010101001110101001001011010010110111110111010111000111110001010100101111101000010000101110100101100110001101111111000010101101111100101011111000110001110101101010010111100011100111111001010100101101100101011011111100101011111000110001111101010001001101001111100011100001101100110100111110001001011000110011110010101011101010110011110111000101111011110100011110101100010110111101001011110000001101111011000000101010011110111010111000111110110010001110101001010001001111000010011111011001001101101000110001001100100111010010001011010001000000111110010101111100011000111000111001111010100101111011110100010000111000000101001011111010110100000111101100001000010100011010111101100111110000111101101100011101110101111000110001101110010000011111001010001111101100101101101111100011110111101000111111001010101100010100000001011011111100100111101101111100111010000101011110111010011101100100001000010110110010110111111010011101001111100100111101101111100111010000101010100110100111110011011100000111011001110101011010010011001111001000101101000111110010111010011100001100010010101110101011010100111101000010111000000110011011010110001011111100101011111000110001111100101010010110110111010111011000111110111010111010011010100011001111001111101111010001111000101010110110010101101100010110111101001010100111101000010111101011011000001110101100010110111101001011111101100101101101111100011110111101000111100011100000111011001110101011111011011000011000111101000010111100100110110110010010110111110010001111001110111001000001100100101001001100100111010010001100111111001010000101111010100110011010010000111000111001111010010001011011101000001001110010110111110000100111110001010010101100111110000100111101011011000001110001111010011010111001010010011111111101000110001001101011000111100101011110111101011110111101000111100010100010110111011001110110001111101000010111101100001000100110100111000100111111111001010000101010110101011111011001100001110101111110001010011010110010111010101100111101110101111101111010001111110111101010110011100001001111010000101111011110100011111101001110110011101010010110000110000100111100001010110111110111101000111111010101010110011100001001111010000101111011110100011111100100111101101110010100100110010011101001000110011111100101000010101011010101111100011100111101001000101101110100000100111001011011111000010011111000101001010110011111000010011110111101000111111001010101100010100000001011011111100110001000001001010010111001110110100111000111100001000111110010111110111101000011101111100001111011011000111011101001110001000001010110111111100011101001101111000110001100000100001110110011101000110111011101011110111010111100011111000100000000110010010000111101001010011001100100111010010001100111111001010000101111010100110011010010000111000111001111010010001011011101000001001110010110111110000100111110001010010101100111110000100111101011011000001111100101101001111100001101000000101011111000000000111101001011000001111100110110011000101101111101000010111101111010001011100001110100001110000001011010101010100110111110000101011011110000101000011100011100101101111101000010111101111010001011100001110110101110110010101011110110110001110001110110001110100011101100101010100111010010111000101101110101011001111100100001000001010100000111100101110100111101100111110100101110000110001001100110011101010100111010010001100111111001010000101010110101011111000111001111010010001011011101000001001110010110111110000100111110001010010101100111110000100111100011111001010101100010100000001011011111100110001000001001010010111101110101111000110101001110100010001110100010001111100110110011001111111100101000010101011010101111110011011010101100111110000101011011111000111110010101011000101000000010110111111001100010000010010100101111011101011111100111001001100101111000110011110100000110011111110001110011100001110011001101001010011111010001111110101000010011101011010101111010011101010110011110001010100000111100101110100111110010110101111011101011110011011010101100110011001001110110011100110101001111111010110101111001010011111000000000111101011010101111101001000101101110100000100111001011011111000010101101111100101001111100101011111000110001110101101010111110001110011110100100010110111010000010011100101101111110110010110110111110001111001001101101100100101101111100100011110000101011000110000100111011011010100101010111111000011111001111001111100101100010110010000010011110000101011011110000011101100111010101100110101101100100010100101000100111110000111110011110011111000111110111011101100111010101101100011101001011000000110001101111001100100111000011011111100011011111101011010101111111011001011101110111010101101000101101101100011110111101010001011111010010101101110011111010000101110110001010110110111110101000100110100111111001010101101110011111101000100000011111010110110101111110100001011101100010101101100000111101100000111100011000010011110000101011011111011000001110001111101101100010001011011110100101010010011001111001001011101011011100111110100001011101100010101101101111101010001001101001111110010101011011100111100010000010101101111111000000000110000100111100101110100010000001111011000101011011000001110001101011110110001010010111110001010100000111000100000001001011011010110111111110000010001010111110110001010110110111000111100010111011001000000101101111000111011000111010010111010000011011101001111010000101111100110001000001000011100101101101011011110100101010011110000101011011110100101110000110010110010010000001011011110001110110001111011110100011111001010111010101101010011110100001011111001101010110000111110010001111000111000011011010111000110000111101101100010011001001110000110011110101101101111101010001001101001111000111001001010111110111101000111110011010011011001000010000101010011110100001011111001000000011000101101111001101001111010011011000010000100010000011101010110011001100111100100000101001011011011101011101100011111011101011110010110100000110011111111001010111101111010111101111010001111000101000011110111101011110111101010001011111110110010100110000000010100101101111010011011000010000100010000011101010110011110111010011100000010110100111011111001101011011110011010011001100100111010010010001010111000111100011001011001111111101110101110001101010011101000100011101000100011111001101100110011110011111110110011010111000111100011001011001111111101110101110001100011000100000011110001101111000100111111101100110101110001111000110010110011111111011101011110010010111010110110101111010111100100000100000001010110000111010110001110110011010111000111100011001011001111111101110101111001001000001101000000110010111100010011111110110011010111000111100011001011001111111101110101111001001110101011011001110100011110000101100010011111110110011010111000111100011001011001111111101110101111011110100011110100110001101101101110100111100001010110111101100111010001101110111010010011110100001011110101101100000111110111101001101001000001011111100100111101101110010100100111111111001111010110101001010111010101100111110111101010001011111010010101101110011101010101001011111011110100111010011101000111101111011010001011011110100101111110010100001011111000010101101111100101011111000110001110001110011111100101101010000101011001001011011001100100111010010011100011011111110110010011101011010101111110010110001100011000101010010111101110101111101111010001111100110110001100011000001011000111101000010111011010010100110011010000111000010011001110001101111101001000011000111101110101110110001010110110100111111111011101100011100010000001110010101011010100100111111110010100111111010100010011010011111011110100011110110101110001000010011111001011011011000101101110010100111101000010111101110100110110000110001111000010101101111101110101101111010000000001010100101100110010011100001101111101001011011111000110001111101010001001101001111100011101101000000110001101111001100111000110111011111011101001111000111011010000001100011011111101101001001110011011000011000111000010101010101100101101111011101011111011110100011110001100011011100100000111110010100001011110110100000011000110111100110010011100001101111111010100010011010011111000111011010000001100011011111110111101010001011111101001010011110110110000110001111011110100111010011101011000101101111010010111110010101111100011000111000001110100001111110110110011011110000101011011111100001111001101001111101011011010111111011110100011111011000011011000111111011100110000101011101010110011111010000101110111101101001111100100000001001011011001100111100100011001111110101010110000110111110111101000101000011111011000011011010111101001001111011101011100011100111101000011100000010110011101011001100110101110110100101011011111101111010100010111111000110001100011111011100101011111000000000111111001000000011000101100101101111001000110101111011010001100010011001001110000110111111101010001001101001111100011101101000000110001101111111011110101000101111110100101001111011011000011000111101011011010111110111010111110111101000111100000010110111111010011111000110000100111101000010111100100100000110100000011001011110001111011110100011110100101001010100111101000010111000101010000011011100100001110100110001000100110100101001111000010101101111101111010001111010010100101010011110100001011100010101000001101110010000111010011000100010011010011010100101010100100000100111100101011111000110001110001110011111000000111110000011111011101011101000111101111101101101010010101011111011101001100100110111101000100001111000101111110111101000111110111000000111110000011111010000101110001110000101010111101000100001101010101010011011001100100111000011011111110101000100110100111110001110110100000011000110111111101111010100010111111010010100111101101100001100011100110011010010101111101111010001111010010111000101100111110100001011100011010100111010001000111010001000111110011011001100111100111111110001110100101110001011001111010010010100111000101100100000111010101100111110010101111011110101111011110100011111101000110001011111101000010111101011001101100110000000101000100011110100101100111111110010101111100011000111000111001111101100001000010101000001010100000110111001011011110111010110111010111100001011111010100001000111010011110100001011100010000000100101101101011011111110000101011011111001001101101100100101101111100100011001100100111000011011111110101000100110100111110001110110100000011000110111111101111010100010111111101110110001110001010101101100000111110000111101110111100000111111001011010011111000011010000001010111110010101111100011000111101001010011110110110000110001111100001111001101001111011101011111000111010110001011011110100101111100101110100010000001111101111010001011000111100101011111000110001110101101010111110001110011111001001101101100110101100100101101111000111011000111101111010001111110010101011000101000001111010000101111011110100010111000011101001100111101110101111000111110110101111100011101100011110111101000101110000111110010110101000000010001100101011001000010011001001110000110111111101010001001101001111100011101101000000110001101111111011101001101100001100010011001001110000110111111101010001001101001111100011101101000000110001101111111011110101000101111110100101001111011011000011000111011011010100101010111101110101111000110001100010000001111000110111100010011111111001010111101111010111011110110100111100110101111100100111101011011001001110000100011001001110100101101001001111111100101011110111101011101111011010011101100110101001101001000001011010000011111010100010011010111010101100111111010011101001111100001111100110010011101101000001111100110110011001110101011001111100101011110111101011110111101000111110010110100000011010100111101000010111011101011011001000011001101010010001111011011110100101111100001010110111101011101101100011000011100010011111001010001011011110100101100100101011110111101010001011111101001010011110110110000110001110000011101100111010101111101101101010010101011110111010111100011000110001000000111100011011110001111100001111011101111000001111000111110001000110010110011111110001111010011000010011110000101011011110001111100010001100101100111111101100101110000110000100111100101011111000110001110001110011111000000111110000011111011101011110010011010100111010111111010100001010110101001111001010111101111010111110000111101110111100000111110010111010011110110011110001111010011000010011110000101011011111001011101001111011001111011001011100001100001001111000010011101000111010010110010000010011110000101011011110001110000101010111101000100000100100110010011100001101111111010100010011010011111000111011010000001100011011111110111010011011000011000100110010011100001101111111010100010011010011111000111011010000001100011011111110111101010001011111101001010011110110110000110001110011001101001000001100011110011011000110001100000101100011101001101010001100011000111000111001111001010101100111011011000000100010110110011111110011001101001000001100011111010011111000110001110100110101000110001100011100011100111100110010011110100011000101100101101111100001010110111100110011010010000011000111110111101011011001011011100001110101111010011010100011000110001110001110011111101111000011010011111100010101001011001111111101111010001111000010101101100110011101011111001101100010001100100010100111100101011111000110001110001110011111101111000011010011111100110110001000011101010100111100001010110111110111101000111111001000001010101011001111001011011111100110110001000110010001010011110010101111100011000111000111001111110111100001101001111010010110000100001110110011101010111111000010101101111101111010001111011001110001010000001100011110100001011110111101000111110010011101010000001101111010011010100011000110001110001110011110000001100110100110001100000101101111100001010110111110001100011000111000101100000101001101011101001101010001100011000111010000100111101111011111101110100110010011011110100010000100110010011101001000101101001110100111011101001111010110110000011111010101011001100011001100111100100010110100111010011101110100111101111010001111000101000011110111101011110111101010001011111000110111111001010111110001100011101100110101110001111000110010110011111111011101011110111101000111110010010111010110110101111010111100101011110111101010011001111001000110111101111010111101111010011101001110001010000111101111010111100101001111100101011111000110001110001110011111000000111110000011111011101011111010001100101111101011011010111111010000101111011110100011111101111010110110010110111000011101011111010000101110110100101001100110100001110000111100011101001011101001010011111010000101111101010101100110001100110010011101001000110111101111010111101111010011101001110001010000111101111010111100101001111100101011111000110001110001110011111000000111110000011111011101011110110000100001010100000101010000011011111110111101000111110010011010000101011001110000111010101100111101101011101001100101010000001101010011110100001011110101101100000111010110001011011110100101111011101011011101011110001110001110011000110110101101110001011011011000111010001100011011111001101101010100101011000111101000010111000111000010101011110100010000110101010101001101100110010011101001000110111101111010111101111010011101001110001010000111101111010111100101001111100101011111000110001110001110011111000000111110000011111011101011110010110100000110011111111011101001100100110111101000100001001111111101110101111100110000010000110001111011101001100100110111101000100001001111111101110101110100101100001101100110010110011100000111110111010011001001101111010001000010011111111011101011101100110101111011101011110010011010000111110001111011101001100100110111101000100001001111111101110101111100101100001111101110001111111101101100110111000101010000011100010000000100101101101011011111110111010011001001101111010001000010011111111100111101011010100101011101010110011111011110101000101111110010100111110010101111100011000111000111001111000100000001001111101001010011110110110000110001001100100111010010001011010011101001111001010111110001100011100011100111110111101000111101101100001100011110010111010001010111110001100011000111101000010111100100100010100110111001110110100111110010110100111110000110100000010101111100101011111000110001110001110011111000000111110000011111011101011101000111010101100111110010101111011110101110101001100101111110111001100001010111010101100111110010000100000110101001100011111001010101101100101101100000110001111100111011101101110100111101000010111101111010001001100111111101001001010010011011111110001000010101101111101000010111110000111000111001000010110110001001111111101000010111101111010001001111000110111110100011101010110011001100111100100111010000101011011111001011101000100000011111101110110001110001010001011110100010000110011101101001110110101110010110110011111111100010000101011011111010000101111011110100011111001000011101111100001100100000111110111110011101101001111100110000001110110100110011111110001000001010110111111001100110100100000110001111101111010110110010110111000011101010100011101101001100111111111000001101111100010000000100101101101011011111100000111010101100111001110001100111000011000010101101111011100010111000110001101110010000011111001010001110111010011110111010111000111001111100011101100100000011000101111101011000101101111010010110011111111011110100111010011111011111011001001011111000111001110010101011011100111110110000110110001100110011110010010111010111110000011011111000100000001001011011010110111111000001110101011001111000100000101011011111110111101000111111010011111000110001011101011001100100111101000010111110011100100110010111110010010011100011011111001100100110100111000000110011001111001001110001101111100010000000100101101101011011111100000111010101100111100010000010101101111111011110100011111101110111011001110101011011000111110111101011011001011011100001110101010011110100001011111001110010011001011110001100111101000001100111110011001001110100100111000110111110001000000010010110110101101111110000011101010110011110001000001010110111111101111010001111110100010111011001110101011001010101110101011001111000110001100011000001011001110100010101011100101001111010000101111001000011100101010101010001100011000100110110000101011110001001100100111010010011100011011111000100000001001011011010110111111000001110101011001111000100000101011011111110111101000111101000101101010010111001110101111001010001100110110011000101101111100100111111101011001011001111011100101001111010000101111001000001010110001010000010000110110101001100100111010010011100011011111000100000001001011011010110111111000001110101011001111000100000101011011111110111101000111111001011011000001001101100011001000110101101100100111010011000101011001100010100111101000010111100100000100011000011100010101000000101011110001001100100111000011010011011010111110101101010111111010010111000011000111101111010100010111001111111110000011011111000100000001001011011010110111100111111100000111010101100111100010000010101101111111001001011101110100101001111000110101010101101100101101110000111010111110100001011110010010000011010000001100101111000100110010011101001001110001101111100010000000100101101101011011111100000111010101100111100010000010101101111110011001101001000001100011111010011111000110001111000010101101111110111101011000001110100111110001100011110100001011100011010100111010001000111010001000111110011011001100111111100001010110111100110011010010000011000111110111101011011001011011100001110101010001110110100110011001001110100100011110100010101111100101001111110000011011111000100000001001011011010110111111000001110101011001100111111110010111010001010111110010100111111000001101111101111011111000001110101011001111000100000101011011111100110011010010000011000111101100101010011101110010101101111110000101011011110011001101001000001100011111010100011011111000001101110011111110001000001010110111111001100110100100000110001110100101110001011001111100001010110111100110011010010000011000111110010011110110110001001111111100101001111100101011111000110001110001110011111000000111110000011111011101011101001100110001001011011111101101100110111101111010100010111110110110000110001111001011101000101011111000110001100011110100001011110010010001010011011100111011010011111001011010011111000011010000001010110011111110001111100010001100101100111111111011100101011111000010101101111100101110100111101100111111011100101011001111111100100001011100110010101001111000010101101111100100100000101011011011111000001010010011111111001000011100001010101100101001011100001011011010011110000101011011111001000001000101111010101011000011111001001001001111111100101011111000110001110001110011111000000111110000011111011101011110010011010100111010111111010100001010110101001111000010101101111010001110101011001111011101011111011110100011111001011010000001101010011110100001011110111101000111110101100001101111010011001100111000001111011110110100011000100111111110010000100100100001100000001001111100010111111100010000100101110011111110001000000010011111000101111111000100001001011100110011110010001011010100001011100111111110010010001010011011110001100011000110111011101100111010101101100010011111111001010011111000000000111100010000000100111110001011111110001000010010111001100110011101010 \ No newline at end of file diff --git a/pydatastructs/huffman/File1.txt b/pydatastructs/huffman/File1.txt new file mode 100644 index 000000000..d5b401228 --- /dev/null +++ b/pydatastructs/huffman/File1.txt @@ -0,0 +1,7 @@ +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane +Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane Ananya Sane \ No newline at end of file diff --git a/pydatastructs/huffman/File2.txt b/pydatastructs/huffman/File2.txt new file mode 100644 index 000000000..eec54f288 --- /dev/null +++ b/pydatastructs/huffman/File2.txt @@ -0,0 +1 @@ +do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at do not go gentle into that good night old age should burn and rave at close of day rage rage against the dying of the light though wise men at \ No newline at end of file diff --git a/pydatastructs/huffman/File3.txt b/pydatastructs/huffman/File3.txt new file mode 100644 index 000000000..18528eabf --- /dev/null +++ b/pydatastructs/huffman/File3.txt @@ -0,0 +1,88 @@ +Friends, Romans, countrymen, lend me your ears; +I come to bury Caesar, not to praise him. +The evil that men do lives after them; +The good is oft interred with their bones; +So let it be with Caesar. The noble Brutus +Hath told you Caesar was ambitious: +If it were so, it was a grievous fault, +And grievously hath Caesar answer’d it. +Here, under leave of Brutus and the rest– +For Brutus is an honourable man; +So are they all, all honourable men– +Come I to speak in Caesar’s funeral. +He was my friend, faithful and just to me: +But Brutus says he was ambitious; +And Brutus is an honourable man. +He hath brought many captives home to Rome +Whose ransoms did the general coffers fill: +Did this in Caesar seem ambitious? +When that the poor have cried, Caesar hath wept: +Ambition should be made of sterner stuff: +Yet Brutus says he was ambitious; +And Brutus is an honourable man. +You all did see that on the Lupercal +I thrice presented him a kingly crown, +Which he did thrice refuse: was this ambition? +Yet Brutus says he was ambitious; +And, sure, he is an honourable man. +I speak not to disprove what Brutus spoke, +But here I am to speak what I do know. +You all did love him once, not without cause: +What cause withholds you then, to mourn for him? +O judgment! thou art fled to brutish beasts, +And men have lost their reason. Bear with me; +My heart is in the coffin there with Caesar, +And I must pause till it come back to me. +Oh me! Oh life! of the questions of these recurring, +Of the endless trains of the faithless, of cities fill’d with the foolish, +Of myself forever reproaching myself, (for who more foolish than I, and who more faithless?) +Of eyes that vainly crave the light, of the objects mean, of the struggle ever renew’d, +Of the poor results of all, of the plodding and sordid crowds I see around me, +Of the empty and useless years of the rest, with the rest me intertwined, +The question, O me! so sad, recurring—What good amid these, O me, O life? +Answer. +That you are here—that life exists and identity, +That the powerful play goes on, and you may contribute a verse. +I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation. +Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon of hope to millions of slaves, who had been seared in the flames of whithering injustice. It came as a joyous daybreak to end the long night of their captivity. But one hundred years later, the colored America is still not free. One hundred years later, the life of the colored American is still sadly crippled by the manacle of segregation and the chains of discrimination. +One hundred years later, the colored American lives on a lonely island of poverty in the midst of a vast ocean of material prosperity. One hundred years later, the colored American is still languishing in the corners of American society and finds himself an exile in his own land So we have come here today to dramatize a shameful condition. +In a sense we have come to our Nation’s Capital to cash a check. When the architects of our great republic wrote the magnificent words of the Constitution and the Declaration of Independence, they were signing a promissory note to which every American was to fall heir. +This note was a promise that all men, yes, black men as well as white men, would be guaranteed the inalienable rights of life liberty and the pursuit of happiness. +It is obvious today that America has defaulted on this promissory note insofar as her citizens of color are concerned. Instead of honoring this sacred obligation, America has given its colored people a bad check, a check that has come back marked “insufficient funds.” +But we refuse to believe that the bank of justice is bankrupt. We refuse to believe that there are insufficient funds in the great vaults of opportunity of this nation. So we have come to cash this check, a check that will give us upon demand the riches of freedom and security of justice. +We have also come to his hallowed spot to remind America of the fierce urgency of Now. This is not time to engage in the luxury of cooling off or to take the tranquilizing drug of gradualism. +Now is the time to make real the promise of democracy. +Now it the time to rise from the dark and desolate valley of segregation to the sunlit path of racial justice. +Now it the time to lift our nation from the quicksand of racial injustice to the solid rock of brotherhood. +Now is the time to make justice a reality to all of God’s children. +I would be fatal for the nation to overlook the urgency of the moment and to underestimate the determination of it’s colored citizens. This sweltering summer of the colored people’s legitimate discontent will not pass until there is an invigorating autumn of freedom and equality. Nineteen sixty-three is not an end but a beginning. Those who hope that the colored Americans needed to blow off steam and will now be content will have a rude awakening if the nation returns to business as usual. +There will be neither rest nor tranquility in America until the colored citizen is granted his citizenship rights. The whirlwinds of revolt will continue to shake the foundations of our nation until the bright day of justice emerges. +We can never be satisfied as long as our bodies, heavy with the fatigue of travel, cannot gain lodging in the motels of the highways and the hotels of the cities. +We cannot be satisfied as long as the colored person’s basic mobility is from a smaller ghetto to a larger one. +We can never be satisfied as long as our children are stripped of their selfhood and robbed of their dignity by signs stating “for white only.” +We cannot be satisfied as long as a colored person in Mississippi cannot vote and a colored person in New York believes he has nothing for which to vote. +No, no we are not satisfied and we will not be satisfied until justice rolls down like waters and righteousness like a mighty stream. +I am not unmindful that some of you have come here out of your trials and tribulations. Some of you have come from areas where your quest for freedom left you battered by storms of persecutions and staggered by the winds of police brutality. +You have been the veterans of creative suffering. Continue to work with the faith that unearned suffering is redemptive. +Go back to Mississippi, go back to Alabama, go back to South Carolina go back to Georgia, go back to Louisiana, go back to the slums and ghettos of our modern cities, knowing that somehow this situation can and will be changed. +Let us not wallow in the valley of despair. I say to you, my friends, we have the difficulties of today and tomorrow. +I still have a dream. It is a dream deeply rooted in the American dream. +I have a dream that one day this nation will rise up and live out the true meaning of its creed. We hold these truths to be self-evident that all men are created equal. +I have a dream that one day out in the red hills of Georgia the sons of former slaves and the sons of former slaveowners will be able to sit down together at the table of brotherhood. +I have a dream that one day even the state of Mississippi, a state sweltering with the heat of oppression, will be transformed into an oasis of freedom and justice. +I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin but by their character. +I have a dream today. +I have a dream that one day down in Alabama, with its vicious racists, with its governor having his lips dripping with the words of interposition and nullification; that one day right down in Alabama little black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers. +I have a dream today. +I have a dream that one day every valley shall be engulfed, every hill shall be exalted and every mountain shall be made low, the rough places will be made plains and the crooked places will be made straight and the glory of the Lord shall be revealed and all flesh shall see it together. +This is our hope. This is the faith that I will go back to the South with. With this faith we will be able to hew out of the mountain of despair a stone of hope. +With this faith we will be able to transform the jangling discords of our nation into a beautiful symphony of brotherhood. +With this faith we will be able to work together, to pray together, to struggle together, to go to jail together, to climb up for freedom together, knowing that we will be free one day. +This will be the day when all of God’s children will be able to sing with new meaning “My country ’tis of thee, sweet land of liberty, of thee I sing. Land where my father’s died, land of the Pilgrim’s pride, from every mountainside, let freedom ring! +And if America is to be a great nation, this must become true. So let freedom ring from the hilltops of New Hampshire. Let freedom ring from the mighty mountains of New York. +Let freedom ring from the heightening Alleghenies of Pennsylvania. +Let freedom ring from the snow-capped Rockies of Colorado. +Let freedom ring from the curvaceous slopes of California. +But not only that, let freedom, ring from Stone Mountain of Georgia. +Let freedom ring from every hill and molehill of Mississippi and every mountainside. +When we let freedom ring, when we let it ring from every tenement and every hamlet, from every state and every city, we will be able to speed up that day when all of God’s children, black men and white men, Jews and Gentiles, Protestants and Catholics, will be able to join hands and sing in the words of the old spiritual, “Free at last, free at last. Thank God Almighty, we are free at last.” \ No newline at end of file diff --git a/pydatastructs/huffman/LICENSE b/pydatastructs/huffman/LICENSE new file mode 100644 index 000000000..16020dd10 --- /dev/null +++ b/pydatastructs/huffman/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Nikhil Agrawal + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pydatastructs/huffman/README.md b/pydatastructs/huffman/README.md new file mode 100644 index 000000000..5a12e2206 --- /dev/null +++ b/pydatastructs/huffman/README.md @@ -0,0 +1,53 @@ +# Huffman coding algorithm to reduce the size of a file and redundancy + +# time complexity: O(nlogn) + +# explaination + +Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based on the frequencies of corresponding characters. The most frequent character gets the smallest code and the least frequent character gets the largest code. + +- The variable-length codes assigned to input characters are Prefix Codes, means the codes (bit sequences) are assigned in such a way that the code assigned to one character is not the prefix of code assigned to any other character. This is how Huffman Coding makes sure that there is no ambiguity when decoding the generated bitstream. +- Let us understand prefix codes with a counter example. Let there be four characters a, b, c and d, and their corresponding variable length codes be 00, 01, 0 and 1. This coding leads to ambiguity because code assigned to c is the prefix of codes assigned to a and b. If the compressed bit stream is 0001, the de-compressed output may be “cccd” or “ccb” or “acd” or “ab”. + +## steps to build a huffman tree + +- Create a leaf node for each unique character and build a min heap of all leaf nodes (Min Heap is used as a priority queue. The value of frequency field is used to compare two nodes in min heap. Initially, the least frequent character is at root) + +- Extract two nodes with the minimum frequency from the min heap. + +- Create a new internal node with a frequency equal to the sum of the two nodes frequencies. Make the first extracted node as its left child and the other extracted node as its right child. Add this node to the min heap. + +- Repeat steps#2 and #3 until the heap contains only one node. The remaining node is the root node and the tree is complete. + +--- + +### code snippet : + +- we will use a min heap to store the nodes of the tree + +```python +class MyHeap(): # Defining a class for the heap + def __init__(self): + self.key = lambda x: x.freq # Criteria to use for the min heap + self.index = 0 # Number of elements in the heap + self._data = [] # Initialising it as an empty heap + + def push(self, item): + heappush(self._data, (self.key(item), self.index, item)) + self.index += 1 + + def pop(self): + self.index -= 1 + return heappop(self._data)[2] + +``` + +--- + +## Results + +we reduced the size of the file from 1.2 MB to 0.6 MB and from Analysis.py we get the error rate also. + +- We have also run the file on different test cases in encoded and decoded format. + + diff --git a/pydatastructs/huffman/Results.txt b/pydatastructs/huffman/Results.txt new file mode 100644 index 000000000..48d66244b --- /dev/null +++ b/pydatastructs/huffman/Results.txt @@ -0,0 +1,90 @@ +n = 15 +k = 10 +p = 0.015 +E = 95 +P(Error) = 0.0475 +E = 115 +P(Error) = 0.0575 +E = 96 +P(Error) = 0.048 +E = 118 +P(Error) = 0.059 +E = 122 +P(Error) = 0.061 +Minimum P(Error) = 0.0475 + +n = 15 +k = 10 +p = 0.1 +E = 952 +P(Error) = 0.476 +E = 942 +P(Error) = 0.471 +E = 967 +P(Error) = 0.4835 +E = 939 +P(Error) = 0.4695 +E = 968 +P(Error) = 0.484 +Minimum P(Error) = 0.4695 + +n = 15 +k = 10 +p = 0.45 +E = 1992 +P(Error) = 0.996 +E = 1996 +P(Error) = 0.998 +E = 1999 +P(Error) = 0.9995 +E = 1993 +P(Error) = 0.9965 +E = 1997 +P(Error) = 0.9985 +Minimum P(Error) = 0.996 + +n = 20 +k = 10 +p = 0.015 +E = 22 +P(Error) = 0.011 +E = 13 +P(Error) = 0.0065 +E = 16 +P(Error) = 0.008 +E = 13 +P(Error) = 0.0065 +E = 13 +P(Error) = 0.0065 +Minimum P(Error) = 0.0065 + +n = 20 +k = 10 +p = 0.1 +E = 521 +P(Error) = 0.2605 +E = 540 +P(Error) = 0.27 +E = 522 +P(Error) = 0.261 +E = 530 +P(Error) = 0.265 +E = 519 +P(Error) = 0.2595 +Minimum P(Error) = 0.2595 + +n = 20 +k = 10 +p = 0.45 +E = 1993 +P(Error) = 0.9965 +E = 1993 +P(Error) = 0.9965 +E = 1993 +P(Error) = 0.9965 +E = 1994 +P(Error) = 0.997 +E = 1989 +P(Error) = 0.9945 +Minimum P(Error) = 0.9945 + diff --git a/pydatastructs/huffman/__init__.py b/pydatastructs/huffman/__init__.py new file mode 100644 index 000000000..8563700e6 --- /dev/null +++ b/pydatastructs/huffman/__init__.py @@ -0,0 +1,9 @@ +from .linear_data_structures import * +from .trees import * +from .miscellaneous_data_structures import * +from .utils import * +from .graphs import * +from .strings import * + +__version__ = "1.0.1-dev" + diff --git a/pydatastructs/huffman/huffman data compression.py b/pydatastructs/huffman/huffman data compression.py new file mode 100644 index 000000000..d3092de5a --- /dev/null +++ b/pydatastructs/huffman/huffman data compression.py @@ -0,0 +1,129 @@ +from heapq import * +import collections +flag = 0 # Flag variable for decoding + +class MyHeap(): # Defining a class for the heap + def __init__(self): + self.key = lambda x: x.freq # Criteria to use for the min heap + self.index = 0 # Number of elements in the heap + self._data = [] # Initialising it as an empty heap + + def push(self, item): + heappush(self._data, (self.key(item), self.index, item)) + self.index += 1 + + def pop(self): + self.index -= 1 + return heappop(self._data)[2] + +class Node: # Defining a class for nodes of the tree + def __init__(self, dat, freq): + self.left = None + self.right = None + self.dat = dat + self.freq = freq + self.cw = "" + + def __repr__(self): + return str(self.dat) + " -> " + str(self.freq) + + +def codegen(head, s): # We reach a leaf and are trying to go further + if head == None: + return + + if head.dat != "#": # A node that is a leaf, as it has an actual symbol, not '#' + head.cw = s + print(head.dat, "->", head.freq, "\t\t\t", head.cw) + + codegen(head.left, s+"0") # Recursively calling the method onto the two branches of the current leaf + codegen(head.right, s+"1") + +def Reverse(lst): # Reversing a list using reverse() + lst.reverse() + return lst + +def encoder(head, s, fout): # Encoder function that writes to a file + if head == None: + return + + if head.dat != "#" and head.dat == s: + fout.write(head.cw) + + encoder(head.left, s, fout) + encoder(head.right, s, fout) + +# Decoder function that is supposed to take an encoded codeword and write the decoded character to a given file + +def decoder(head, ch, fout): + global flag + + if head == None: + return + + if head.dat != "#" and head.cw == ch: + fout.write(head.dat) + flag = 1 + return + + decoder(head.left, ch, fout) + decoder(head.right, ch, fout) + +# MAIN STARTS HERE NOOB + +with open('File1.txt', 'r') as info: + count = collections.Counter(info.read()) + total = sum(count.values()) + +ncount = count.most_common() +nheap = MyHeap() +dist = ncount.__len__() +i = 0 +for i in range(dist): + temp = Node(ncount[i][0], ncount[i][1]) + nheap.push(temp) + +while nheap.index != 1: + l = nheap.pop() + r = nheap.pop() + temp = Node("#", l.freq+r.freq) + temp.left = l + temp.right = r + nheap.push(temp) + +codegen(nheap._data[0][2], "") + +cd = open("Encoded1.txt", 'w') +info = open("File1.txt", 'r') +dcd = open("Decoded1.txt", 'w') +ptext = info.read() +insize = ptext.__len__() +i = 0 +for i in range(insize): + encoder(nheap._data[0][2], ptext[i], cd) + +cd.close() +cur = "" +rcd = open("Encoded1.txt", 'r') +while 1: + encoded = rcd.read(1) + if not encoded: + break + cur += encoded + decoder(nheap._data[0][2], cur, dcd) + if flag == 1: + flag = 0 + cur = "" + +rcd.close() +dcd.close() +info.close() + +# The encoded files have characters and not bits in them. +# So for a comparison of file sizes their actual sizes in bytes need be divided by 16. +# This is because each character takes 2 bytes, which is 16 bits instead of the 1 bit they are supposed to take. +# According to this, we get + +# Encoded1.txt = 19920/16 = 1245 bytes, Initial size of File1.txt = 7245 bytes; compressed 5.82 times +# Encoded2.txt = 27648/16 = 1728 bytes, Initial size of File2.txt = 7149 bytes; compressed 4.137 times +# Encoded3.txt = 43319/16 = 2707.4375 bytes, Initial size of File3.txt = 9851 bytes; compressed 3.638 times