题目:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique B....
分类:
编程语言 时间:
2014-08-01 04:53:11
阅读次数:
272
题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "ad....
分类:
编程语言 时间:
2014-08-01 02:20:41
阅读次数:
236
为了表现图中顶点之间的关联,我们可以使用邻接矩阵来实现图结构。所谓的邻接矩阵,就是一个反应边与边之间联系的二维数组。这个二维数组我们用matrix[numV][numV]表示,其中numV是顶点数。
对于无权图
若顶点Vi和Vj之间有边,则matrix[Vi][Vj]=1;否则matrix[Vi][Vj]=0。
对于有权图
若顶点Vi和Vj之间有边,且权值为weight,则matrix[Vi][Vj]=weight;否则matrix[Vi][Vj]=0或MAXWEIGHT(取最小权值或最大权值)。...
分类:
其他好文 时间:
2014-07-31 23:56:30
阅读次数:
296
This assignment will help you practice and understand better the Binary Tree and Binary Search Tree data structures, their operations and implementati...
分类:
编程语言 时间:
2014-07-31 23:20:10
阅读次数:
270
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.算法:根据有序数组,生...
分类:
其他好文 时间:
2014-07-31 23:20:00
阅读次数:
270
1.首先要安装编译源码用的编译器gcc&g++,安装方式很简单,先用yum search gcc搜索出包,然后选择适合自己的版本复制全名,用yum intall gcc_XXX来进行安装即可。2.安装openssl以及ncurses-devel。安装方式和1一样。3.从这里http://www.er...
分类:
其他好文 时间:
2014-07-31 23:18:20
阅读次数:
254
Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol...
分类:
其他好文 时间:
2014-07-31 23:13:00
阅读次数:
223
Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre...
分类:
其他好文 时间:
2014-07-31 23:11:40
阅读次数:
225
题目链接:http://poj.org/problem?id=3233解题报告:输入一个边长为n的矩阵A,然后输入一个k,要你求A + A^2 + A^3 + A^4 + A^5.......A^k,然后结果的每个元素A[i][j] % m。(n 2 #include 3 #include ...
分类:
其他好文 时间:
2014-07-31 20:43:37
阅读次数:
229
1 ?引言? ? ??Grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并?把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。G...
分类:
系统相关 时间:
2014-07-31 17:26:59
阅读次数:
466