![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
文章平均质量分 74
dawn_ricardo_y
这个作者很懒,什么都没留下…
展开
-
初次利用并查集解决问题
这是我第一次学习幷查集,为了解决无向图中两个点是否在一个连通图的问题。由于数据比较大,直接搜索很容易超时,时间复杂度比较高。幷查集相对而言就好的多了。一下是代码 // using disjoint algorithm #include #include using namespace std; int f[100001]; int find(int x) { //find root原创 2016-12-10 12:37:25 · 283 阅读 · 0 评论 -
sicily AVLTree
Description 给出结点的插入序列,构造AVL Tree。 Input 第一行含一个整数t(0 每个测试样例包含两行;第1行为一个整数n,表示插入的结点数;第2行依照插入顺序给出n个结点的数值(整数),之间用一个空格分隔。 Output 对每个测试样例单独一行输出对应AVL Tree的前序遍历序列,每输出一个结点的数值(包括最原创 2016-12-10 12:57:59 · 312 阅读 · 0 评论 -
sicily Binary Search
Description 实现二分查找函数,函数接口如下。 /* size为数组s的实际大小。 假定s非递减有序,如果s中存在值为target的元素, 则返回最后一次出现的位序号,否则返回-1表示不存在。 位序号从0开始计。*/ int binSearch(const int s[], const int size, const int target) { // 请将实现代码添原创 2016-12-10 13:01:21 · 386 阅读 · 0 评论 -
[Leetcode][648][Replace Words] stringstream学习
题目描述 In English, we have a concept called root, which can be followed by some other words to form another longer word - let’s call this word successor. For example, the root an, followed by other, wh...原创 2018-09-03 23:25:34 · 132 阅读 · 0 评论