1 1 vote what is Space complexity of Huffman coding? Algorithms huffman-code algorithms space-complexity + – Akash Kumar Roy 5.7k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 2 2 votes If we have n symble then we need to store each Symble in Array so Space complexity = O(n) abhishekmehta4u answered Apr 26, 2018 • selected Apr 26, 2018 by Akash Kumar Roy abhishekmehta4u comment Share Follow See all 14 Comments 14 14 Comments reply Show 11 previous comments Akash Kumar Roy commented Apr 27, 2018 reply Follow flag Thank you for such a detailed explanation. I understood the concept but what about Huffman coding's space complexity? Is it O(n) or O(1). According to my understanding, we need n extra space to keep track of frequencies of the characters. What is your opinion on that. 0 0 replyShare ankitgupta.1729 commented Apr 27, 2018 reply Follow flag @Akhilesh , I have given the link of University of Texas where it is mentioned that :- We often speak of "extra" memory needed, not counting the memory needed to store the input itself. So, we should not have to consider the input size to find the space complexity of an algorithm. @Akash ,it should be O(n) which you have already mentioned because we have to store frequencies of characters from the input file seperately in the array. 4 4 replyShare rajatmyname commented Feb 7, 2019 reply Follow flag Does the input will not contain the elements array and its frequency as its input? 0 0 replyShare Please log in or register to add a comment.
0 0 votes To obtain Huffman coding we use data structure called min heap. At the initial phase all the nodes has to be present in heap(satisfying min-heap property). If there are n elements in tree then space complexity will be O(n) which is extra space required. Sarang answered Dec 20, 2019 Sarang comment Share Follow 0 reply Please log in or register to add a comment.