摘要: 基于线性探测的散列表的代码: public void put(Key key, Value val) { if (val == null) { delete(key); return; } // double table size if 50% full if (n >= m/2) resize(2 阅读全文
posted @ 2021-01-18 21:26 wangheq 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 算法四中给出了红黑树的构造代码: import edu.princeton.cs.algs4.Queue; import edu.princeton.cs.algs4.StdOut; public class RedBlackLiteBST<Key extends Comparable<Key>, 阅读全文
posted @ 2021-01-18 15:57 wangheq 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 中序遍历就是将一个二叉树的所有结点按照顺序打印出来(假定这个数的构造是左节点小于父节点,右节点大于父节点) private void print(Node x) { if (x == null) return; print(x.left); StdOut.println(x.key); print( 阅读全文
posted @ 2021-01-18 10:24 wangheq 阅读(147) 评论(0) 推荐(0) 编辑