Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
分类:
其他好文 时间:
2014-11-25 00:02:20
阅读次数:
428
【题目】
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
【解析】
分治:用快慢指针找到链表的中点,作为树的root,然后二分——中点之前的链表和中点之后的链表分别再构造二叉平衡树。
/**
* Defin...
分类:
其他好文 时间:
2014-11-24 22:39:00
阅读次数:
218
leetcode-Binary Tree Level Order Traversal 二叉树层序遍历
#include
#include
using namespace std;
typedef struct BiTree
{
int val;
struct BiTree *lchild;
struct BiTree *rchild;
}BiTree;
void main(...
分类:
其他好文 时间:
2014-11-24 22:35:13
阅读次数:
202
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9 20
...
分类:
其他好文 时间:
2014-11-24 22:33:13
阅读次数:
272
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Given binary ...
分类:
其他好文 时间:
2014-11-24 22:31:45
阅读次数:
196
算法思想:采用队列结构按层次遍历,遍历K层时记录叶子的个数
int LeafKlevel(BiTree bt, int k){
//求二叉树bt的第k(k >1)层上叶子的节点个数
if(bt == NULL || k < 1)
return 0;
BiTree p=bt,Q[]; //Q是队列,元素是二叉树节点的指针
int...
分类:
其他好文 时间:
2014-11-24 19:19:09
阅读次数:
393
linux目录架构/ 根目录/bin 常用的命令 binary file 的目錄/boot 存放系统启动时必须读取的档案,包括核心 (kernel) 在内/boot/grub/menu.lst GRUB设置/boot/vmlinuz 内核/boot/initrd 核心解壓縮所需 RAM Disk/d...
分类:
系统相关 时间:
2014-11-24 18:57:48
阅读次数:
281
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
#include
#include
char* addBinary(char a[], char b[]) {
int na=strlen(a);
...
分类:
其他好文 时间:
2014-11-24 17:13:45
阅读次数:
191
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.C++实现代码:#inclu...
分类:
其他好文 时间:
2014-11-24 11:47:33
阅读次数:
281
操作命令:show binlog events in 'binlog.000016' limit 10;reset master 删除所有的二进制日志flush logs 产生一个新的binlog日志文件show master logs; / show binary logs; 查看二进制文件列表和...
分类:
数据库 时间:
2014-11-24 11:43:43
阅读次数:
164