摘要: 题目来源:http://www.patest.cn/contests/mooc-ds/04-%E6%A0%916 In 1953, David A. Huffman published his paper "A Method for the Construction of Minimum-Redun 阅读全文
posted @ 2015-08-31 19:32 llhthinker 阅读(1727) 评论(0) 推荐(0) 编辑
摘要: 对于一个集合常见的操作有:判断一个元素是否属于一个集合;合并两个集合等等。而并查集是处理一些不相交集合(Disjoint Sets)的合并及查询问题的有利工具。 并查集是利用树结构实现的。一个集合用一棵树来表示,而多个集合便是森林。并查集中的“并”是将两个集合合并即两棵树合并成一颗树;“查”是... 阅读全文
posted @ 2015-08-30 22:09 llhthinker 阅读(967) 评论(0) 推荐(1) 编辑
摘要: 对于一棵普通的二叉查找树而言,在进行多次的插入或删除后,容易让树失去平衡,导致树的深度不是O(logN),而接近O(N),这样将大大减少对树的查找效率。一种解决办法就是要有一个称为平衡的附加的结构条件:任何节点的深度均不得过深。有一种最古老的平衡查找树,即AVL树。 AVL树是带有平衡条件的二... 阅读全文
posted @ 2015-08-29 23:41 llhthinker 阅读(1381) 评论(0) 推荐(0) 编辑
摘要: 03-树3. Tree Traversals Again (25)题目来源:http://www.patest.cn/contests/mooc-ds/03-%E6%A0%913An inorder binary tree traversal can be implemented in a non-... 阅读全文
posted @ 2015-08-21 19:05 llhthinker 阅读(4478) 评论(0) 推荐(1) 编辑
摘要: 03-树2. List Leaves (25)题目来源:http://www.patest.cn/contests/mooc-ds/03-%E6%A0%912Given a tree, you are supposed to list all the leaves in the order of t... 阅读全文
posted @ 2015-08-21 18:50 llhthinker 阅读(4680) 评论(0) 推荐(0) 编辑
摘要: 对于一种数据结构而言,遍历是常见操作。二叉树是一种基本的数据结构,是一种每个节点的儿子数目都不多于2的树。二叉树的节点声明如下:1 typedef struct TreeNode *PtrToNode;2 typedef struct TreeNode *BinTree;3 4 struct T... 阅读全文
posted @ 2015-08-21 18:11 llhthinker 阅读(71091) 评论(8) 推荐(11) 编辑
摘要: ###算法一:穷举式地尝试所有的可能### int maxSubsequenceSum(const int a[], int n) { int i, j, k; int thisSum, maxSum = 0; for (i = 0; i maxSum) ... 阅读全文
posted @ 2015-07-25 12:19 llhthinker 阅读(690) 评论(0) 推荐(0) 编辑
TOP