I read this algorithm for using 2 queues to implement Huffman codes, and it claims that with sorted input the runtime can be O(n): https://www.geeksforgeeks.org/efficient-huffman-coding-for-sorted-input-greedy-algo-4/
I do not quite understand why it is O(n): the algorithm iterate all the initial N nodes, however it wold construct merged node and enqueue to the 2nd queue during the iteration. It seems like the whole iteration process would take O(n log n) for me.