28、外存算法
1、传统算法的局限性

2、外存模型



3、外存寻找最小值

4、外存二分搜索


5、外存排序基础


6、外存合并两个有序数组





7、为什么内存越大,计算机性能越好





8、外存排序的重要优化




9、外存合并 k 个有序数组
public class MergeKLists {
    public ListNode mergeKLists(ListNode[] lists) {
        if (lists == null || lists.length == 0) return null;
        if (lists.length == 1) return lists[0];
        // 最小堆
        PriorityQueue<ListNode> pq = new PriorityQueue<>(Comparator.comparingInt(o -> o.val));
        for (ListNode head : lists) {
            if (head != null) pq.add(head);
        }
        ListNode dummyHead = new ListNode();
        ListNode prev = dummyHead;
        while (!pq.isEmpty()) {
            ListNode node = pq.remove();
            prev.next = node;
            prev = prev.next;
            if (node.next != null) pq.add(node.next);
        }
        return dummyHead.next;
    }
}



10、k 分数据是一种算法思想



本文来自博客园,作者:lidongdongdong~,转载请注明原文链接:https://www.cnblogs.com/lidong422339/p/17340316.html

                
            
        
浙公网安备 33010602011771号