码迷,mamicode.com
首页 >  
搜索关键字:complete binary search tree    ( 35177个结果
【LeetCode】- Search Insert Position(查找插入的位置)
[ 问题: ] Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in th...
分类:其他好文   时间:2014-07-22 23:01:15    阅读次数:270
LeetCode - Best Time to Buy and Sell 3
这道题在前两个的基础上做稍微改进就可以。下面是AC代码: 1 /** 2 * Design an algorithm to find the maximum profit. You may complete at most two transactions. 3 * @pa...
分类:其他好文   时间:2014-07-22 23:01:13    阅读次数:251
Ubuntu 12.04 安装WPS
1. 安装包下载:wps官网的 debian .deb 包 2 根据wifi说明,需要一下三个lib: libtiff.so.4 libpng12.so.0 libjpeg.so.62 通过以下命令查看是否具备: liaoqianwen@liaoqianwen-F80S:~ aptitude search libtiff 如果没有,安装: liao...
分类:其他好文   时间:2014-07-22 22:59:35    阅读次数:343
哈夫曼树 POJ 3253 Fence Repair
竟然做过原题,一眼看上去竟然没感觉。。。 哈夫曼树定义:给定n个权值作为n个叶子结点,构造一棵二叉树,若带权路径长度达到最小,称这样的二叉树为最优二叉树,也称为哈夫曼树(Huffman tree)。哈夫曼树是带权路径长度最短的树,权值较大的结点离根较近。 1、路径和路径长度 在一棵树中,从一个结点往下可以达到的孩子或孙子结点之间的通路,称为路径。通路中分支的数目称为路径长度。若规...
分类:其他好文   时间:2014-07-22 22:59:32    阅读次数:293
sed
sed‘s/^/\//g‘4行首增加指定字符提取网页中的播放地址:#!/bin/bash printf"enteryourdir:" readdir echo"$dirisxx" cd$dir echo`pwd` forfilein`ls.` do if[-d$file];then echo$file cd$file echo`pwd` tree`pwd`|grepplay|sed‘s/.*//g‘>11 tree`pwd`|grepplay|sed‘s/.*//g..
分类:其他好文   时间:2014-05-03 00:53:15    阅读次数:336
Balanced Binary Tree
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-05-02 07:05:08    阅读次数:311
[leetcode] Best Time to Buy and Sell Stock
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
分类:其他好文   时间:2014-05-02 00:37:20    阅读次数:349
数据结构《17》---- Ternary Search Tree
一、 序言 上一篇文章中,给出了 trie 树的一个实现。可以看到,trie 树有一个巨大的弊病,内存占用过大。 本文给出另一种数据结构来解决上述问题---- Ternary Search Tree (三叉树) 二、数据结构定义 Trie 树中每个节点包含了 26 个指针,但有很大一部分的指针是 NULL 指针,因此浪费了大量的资源。 一种改进措施就是,以一棵树来代替上述的指针数组。...
分类:其他好文   时间:2014-05-01 17:49:30    阅读次数:326
【CareerCup】Trees and Graphs—Q4.3
题目: Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height. 翻译: 给定一个有序数组(递增),写程序构建一棵具有最小高度的二叉树。 思路: 要使二叉树的高度最小,则要尽量使其左右子树的节点数目相当,自然就考虑到将其构造成为二叉排序树,且将有序数组的中间大的数作为根节点,这样得到的二叉树的高度便是最小的。...
分类:其他好文   时间:2014-05-01 17:48:45    阅读次数:321
Unique Binary Search Trees -- LeetCode
原题链接: http://oj.leetcode.com/problems/unique-binary-search-trees/  这道题要求可行的二叉查找树的数量,其实二叉查找树可以任意取根,只要满足中序遍历有序的要求就可以。从处理子问题的角度来看,选取一个结点为根,就把结点切成左右子树,以这个结点为根的可行二叉树数量就是左右子树可行二叉树数量的乘积,所以总的数量是将以所有结点为根的可行结果...
分类:其他好文   时间:2014-04-30 22:12:39    阅读次数:244
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!