Two elements of a binary search tree (BST) are swapped by mistake.
分类:
其他好文 时间:
2014-07-03 19:44:18
阅读次数:
161
Given a binary tree, determine if it is a valid binary search tree (BST).
分类:
其他好文 时间:
2014-07-03 19:36:49
阅读次数:
196
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
分类:
其他好文 时间:
2014-07-03 19:10:40
阅读次数:
201
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
分类:
其他好文 时间:
2014-07-03 18:55:48
阅读次数:
236
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1.....
分类:
其他好文 时间:
2014-07-02 22:13:23
阅读次数:
191
直接上代码
/*
* bst.h
*
* Created on: Jun 20, 2014
* Author: buyuanyuan
*/
#ifndef BST_H_
#define BST_H_
#include
#include
typedef enum Color {
RED = 0,
BLACK = 1
} Color;
typede...
分类:
其他好文 时间:
2014-07-01 06:11:04
阅读次数:
224
1. 二叉查找树的定义:
左子树不为空的时候,左子树的结点值小于根节点,右子树不为空时,右子树的结点值大于根节点,左右子树分别为二叉查找树
2. 二叉查找树的最左边的结点即为最小值,要查找最小值,只需遍历左子树的结点直到为空为止,同理,最右边的结点结尾最大值,要查找最大值,只需遍历右子树的结点直到为空为止。二叉查找树的插入查找和删除都是通过递归的方式来实现的,删除一个结点的时候,先找到这个结点...
分类:
编程语言 时间:
2014-06-29 22:08:33
阅读次数:
316
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 BST's...
分类:
其他好文 时间:
2014-06-27 18:22:07
阅读次数:
191
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key....
分类:
其他好文 时间:
2014-06-27 09:15:12
阅读次数:
196