• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 27 下一页
2014年3月27日
Data Structure Binary Tree: Check for Children Sum Property in a Binary Tree
摘要: http://www.geeksforgeeks.org/check-for-children-sum-property-in-a-binary-tree/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struct node { 9 int data;10 struct node *left, *right;11 node() : data(0), left(NULL), right(NULL) { }12 node(int d) ... 阅读全文
posted @ 2014-03-27 10:21 ying_vincent 阅读(153) 评论(0) 推荐(0)
Data Structure Binary Tree: Level order traversal in spiral form
摘要: http://www.geeksforgeeks.org/level-order-traversal-in-spiral-form/ 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 struct node { 9 int data;10 struct node *left, *right;11 node() : data(0), left(NULL), right(NULL) { }12 node(int d) : data(d), l... 阅读全文
posted @ 2014-03-27 09:52 ying_vincent 阅读(178) 评论(0) 推荐(0)
2014年3月12日
Data Structure Binary Search Tree: Inorder Successor in Binary Search Tree
摘要: 1 struct node { 2 int val; 3 node *left; 4 node *right; 5 node *parent; 6 node() : val(0), left(NULL), right(NULL) { } 7 node(int v) : val(v), left(NULL), right(NULL) { } 8 }; 9 10 node* insert(int n, node *root) {11 if (root == NULL) {12 root = new node(n);13 ... 阅读全文
posted @ 2014-03-12 04:54 ying_vincent 阅读(217) 评论(0) 推荐(0)
2014年2月25日
Algorithm: bit manipulation
摘要: 1. 一个数的从右起第p1位和第p2位swap n位 1 unsigned int swapBits(unsigned int x, unsigned int p1, unsigned int p2, unsigned int n) { 2 unsigned int set1 = (x >> p1) & ((1 > p2) & ((1 > (sizeof(int) * 8 - 1)));3 }also can use division4. count bit set in an integer1 int countsetbits(int x) {2 in 阅读全文
posted @ 2014-02-25 10:13 ying_vincent 阅读(198) 评论(0) 推荐(0)
2014年2月20日
Algorithm: pattern searching
摘要: kmp算法:用一个数组保存了上一个需要开始搜索的index,比如AAACAAA就是0, 1, 2, 0, 1, 2, 3, ABCABC就是0, 0, 0, 1, 2, 3,复杂度O(M+N) 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 int main()10 {11 string pattern = "ABCABC";12 string s = "ABCABCABCABCBCABC";13 vector lps(pattern. 阅读全文
posted @ 2014-02-20 06:12 ying_vincent 阅读(337) 评论(0) 推荐(0)
2014年2月10日
Algorithm: dynamic programming
摘要: 1. Longest Increasing Subsequence (LIS) problemunsorted array, calculate out the maximum length of subsequence with non-decreasing order.lis[i] = lis[... 阅读全文
posted @ 2014-02-10 12:57 ying_vincent 阅读(189) 评论(0) 推荐(0)
2014年2月8日
Algorithm: inversion
摘要: inversion就是逆序对题目:现给出一个数列,求该数列中的逆序对数(逆序数)。本节给出三种方法:方法一是最直接的暴力方法;方法二是基于归并分治的思想;方法三是基于线段树的。【解法一】暴力方法最直接,也最容易想到,两层for循环就可以算出来逆序数:每遇到一个元素回头遍历寻找比其大的元素个数即可,当然向后寻找比其小的元素个数也可以,复杂度为O(n^2),代码:123456789101112int sum = 0;for(int i = 0; i arr[j]){++sum;}}}return sum;【解法二】这种方法最初见于《算法导论》,这里先附上《算法导论》2-4关于逆序对的几点讨论:1. 阅读全文
posted @ 2014-02-08 12:44 ying_vincent 阅读(455) 评论(0) 推荐(0)
2014年2月3日
Database: coursera assignment 1
摘要: q.1:Find the titles of all movies directed by Steven Spielberg.select title from moviewhere director = 'Steven Spielberg'q.2:Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order.select yearfrom movie, ratingwhere movie.mid = rating.mid and rati 阅读全文
posted @ 2014-02-03 12:25 ying_vincent 阅读(498) 评论(0) 推荐(0)
2014年2月2日
Database: index
摘要: The whole point of having an index is to speed up search queries by essentially cutting down the number of records/rows in a table that need to be examined.an index is a data structure (most commonly a B- tree) that stores the values for a specific column in a table. An index is created on a column 阅读全文
posted @ 2014-02-02 12:37 ying_vincent 阅读(150) 评论(0) 推荐(0)
Database: key
摘要: super-key:Any key that has more columns than necessary to uniquely identify each row in the table is called a super-key (think of it as a super-set).candidate key:if the key has the minimum amount of columns necessary to uniquely identify each row then it is called a minimal super-key. A minimal sup 阅读全文
posted @ 2014-02-02 11:44 ying_vincent 阅读(304) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 27 下一页
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3