tpqueue
is implemented using a heap,
what is the complexity of the code above and why?
This algorithm doesn't find just the single k-th smallest, it finds the smallest k elements and stores them in the vector. As a result, the vector might be much smaller than it was originally, e.g., if you find the 10 smallest elements in a 1000-element vector.
This algorithm has two steps:
Complete the function below and determine what it's big-Oh complexity is assuming tpqueue is implemented using a heap.
character | frequency | character | frequency |
---|---|---|---|
'a' | 5 | 't' | 3 |
's' | 1 | 'o' | 1 |
'e' | 8 | 'r' | 2 |
Draw the Huffman tree for these characters. Make a statement about the shape of the tree as a "good" Huffman tree as the shape is related to the frequencies which are from a Fibonacci sequence:
1 1 2 3 5 8 13 21 ...where each number after the first two is the sum of the previous two numbers.