随笔分类 - 数据结构
摘要:* 什么是二叉搜索树?其形式就是二叉树,对于每个节点x,其左子树的值<=x.value,右子树的值>=x.value。 * 对于二叉搜索树,我们可以使用中序遍历,得到树上从小到大所有的元素。时间复杂度平均为O(n)。 * 当我们想要查询二叉搜索树中某个关键字应该怎么做呢?由于二叉搜索树左子树和右子树
阅读全文
摘要:堆排序的时间复杂度是O(nlgn),与归并排序一样,但它又与插入排序一样具有空间原址性:任何时候都只需要常数个额外的元素空间存储临时数据。 什么是堆?一般堆用数组存储,表现出近似完全二叉树形式,树上的每一个结点对应数组中的一个元素。除了最底层外,该树是完全充满的且从左至右填充。 maxHeapify
阅读全文
摘要:In Galgame We TrustTime Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)As we all know, there are many interesting (H) game...
阅读全文
摘要:题目描述:N(3N20000)ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To improve...
阅读全文
摘要:题目大意:每次输入两个顶点,如果与已输入的顶点可以连成一个环则不放入这两个顶点,否则添加这两个顶点。本题考查图问题中判断是否为环,可用并查集解决,具体见代码。//simonPR#include #include #include #include #include #include #include...
阅读全文

浙公网安备 33010602011771号