摘要:
合并两个排序的列表 题目描述 输入两个递增排序的链表,合并这两个链表并使新链表中的结点仍然是按照递增排序的。 数据范围 链表长度 [0,500][0,500]。 样例 输入:1->3->5 , 2->4->5 输出:1->2->3->4->5->5 代码实现 迭代版本 struct ListNode 阅读全文
摘要:
public static int height(BinTree T) { if (T == null) { return -1; } else { return Math.max(height(T.left), height(T.right)) + 1; } } /** Return the di 阅读全文
摘要:
1.说明下列每对scanf格式串是否等价?如果不等价,请指出它们的差异。 (c) "%f"与"%f "。 在 `scanf` 函数中,`"%f"` 和 `"%f "` 这两种格式的区别在于后面的空格。 1. `scanf("%f", &variable);` 这种情况下,`scanf` 会读取并解析 阅读全文
摘要:
public static void zorkSort(int[] A, int k) { int i; int n = A.length; i = 0; PriorityQueue<Integer> pq = new PriorityQueue<>(); while (i < k) { pq.ad 阅读全文
摘要:
阅读全文
摘要:
If we start with a hash table of size 2 and double when the load factor exceeds some constant. Why is this procedure for setting sizes suboptimal from 阅读全文
摘要:
这是一个递归函数,其中有一个对自身的四次调用,并且在每次调用之后,输入的大小(N)减半。在函数的最后部分,有一个以Θ(N²)时间复杂度运行的函数g(N)。 现在让我们来计算这个函数的时间复杂度。 如果我们设T(N)为这个函数的时间复杂度,我们可以通过观察代码中的各个部分来构建一个递归方程。 递归的部 阅读全文
摘要:
假设有一个循环数组,它的容量为capacity,当指针在最后一个位置的时候,再次前移时,就会变为这个数组的0号位置。如何用一条语句来实现? first = (first + 1) % capacity; 取模!!! 阅读全文
摘要:
public class AltList<X, Y> { private X item; private AltList<Y, X> next; AltList(X item, AltList<Y, X> next) { this.item = item; this.next = next; } p 阅读全文