07 2016 档案
摘要:The article describes an approach to solving the problem of finding the LCA of two nodes in a tree by reducing it to a RMQ problem. Lowest Common Ance
阅读全文
摘要:Given values of two nodes in a Binary Search Tree, write a c program to find the Lowest Common Ancestor (LCA). You may assume that both the values exi
阅读全文
摘要:Given a binary tree (not a binary search tree) and two values say n1 and n2, write a program to find the least common ancestor. Following is definitio
阅读全文
摘要:set集合容器:实现了红黑树的平衡二叉检索树的数据结构,插入元素时,它会自动调整二叉树的排列,把元素放到适当的位置,以保证每个子树根节点键值大于左子树所有节点的键值,小于右子树所有节点的键值;另外,还得保证根节点左子树的高度与右子树高度相等。 平衡二叉检索树使用中序遍历算法,检索效率高于vector
阅读全文
摘要:蔡勒(Zeller)公式,是一个计算星期的公式,随便给一个日期,就能用这个公式推算出是星期几。 公式: (或者是: ) 若要计算的日期是在1582年10月4日或之前,公式则为 以1582年9月3日为例: 1582年9月3日后:w = (d + 2*m+3*(m+1)/5+y+y/4-y/100+y/
阅读全文
摘要:求最大的和最小的原理是一样的,只不过是求最大的在应用中用的比较多。举个比较常见的例子,大家都会购物吧,购物的时候如果去京东商城,当搜索某件商品的时候,搜索后的页面会呈现很多该类型的商品,但是京东总会给我们一些推荐,那么这个推荐是依据什么呢?其实道理很简单,京东的后台会记录客户浏览或者购买的某件商品的
阅读全文