- 博客(53)
- 收藏
- 关注
原创 python包管理工具关系
刚开始学习Python时,在看文档和别人的blog介绍安装包有的用easy_install, setuptools, 有的使用pip,distribute,那麽这几个工具有什么关系呢,看一下下面这个图就明白了可以看到distribute是setuptools的取代,pip是easy_install的取代。 关于这些包工具可以参考 http://guide.pyt
2017-08-25 10:17:39
351
原创 Win7下安装Python pip工具
很多Python的工具包的安装,用一个pip install ** 就可以了,看得我这个晕啊。。。于是搞了好几个小时,终于明白了pip 和easy_install、distribute 一样,是安装python工具包的便捷管理工具。这几个管理工具的关系在:http://jiayanjujyj.iteye.com/blog/1409819可以看到distribute是se
2017-08-25 10:16:56
519
原创 shell范例
PARTITION_LOG_PATH=/tmp/obs_partition_log####################################################################### DESCRIPTION: 输出log到指定日志文件# CALLS : 无# INPUT : 日志记录字符串# OUTPUT
2017-08-04 18:33:00
345
原创 shell范例
#!/usr/bin/env bash# shell workspaceWORK_DIR={{path.partition_work_dir}}DISK_NAME={{disk.common_100G}}# size of partition 1, size unit is GPARTITION_1_SIZE=30###############################
2017-08-04 18:32:22
316
原创 最近点问题
package divideconquer;import java.util.Arrays;import java.util.Comparator;class Point{ int x; int y; public Point(int x, int y) { this.x = x; this.y = y; }}public class ClosestPairofPoi
2014-07-13 16:02:29
437
原创 判断一颗二叉树是不是查找二叉树
package bst;public class isBSTornot { /** * 本质用中序遍历 * @param args */ public static TreeNode pre = null; public static boolean isbst(TreeNode root){ if(root==null) return true; if(!isbs
2014-07-04 13:32:05
500
原创 只用一个栈实现二叉树的非递归后序遍历
package tree;import java.util.Stack;public class IterativePostorderTraversalone { /** * 只用一个栈实现二叉树的非递归后序遍历 * @param args */ public static void printpost(TreeNode root){ Stack stack = ne
2014-07-01 19:49:27
811
原创 用俩个栈实现二叉树的非递归后序遍历
package tree;import java.util.Stack;public class IterativePostorderTraversal { /** * 用一个栈实现二叉树的非递归后序遍历 * @param args */ public static void printpost(TreeNode root){ Stack stack1 = new S
2014-07-01 19:18:04
746
原创 带栈的二叉树非递归先序遍历
package tree;import java.util.Stack;public class IterativePreorderTraversal { /** * 带栈的二叉树前序非递归遍历 * @param args */ public static void printpre(TreeNode root){ Stack stack = new Stack<>(
2014-07-01 15:49:32
441
原创 Construct Full Binary Tree from given preorder and postorder traversals
package tree;public class ConstructFullBinaryTree { /** * Construct Full Binary Tree from given preorder and postorder traversalsGiven two arrays that represent preorder and postorder traversal
2014-07-01 15:08:56
502
原创 Construct a special tree from given preorder traversal
package tree;public class Construct { /** * * Construct a special tree from given preorder traversalGiven an array ‘pre[]‘ that represents Preorder traversal of a spacial binary tree where
2014-07-01 13:54:55
446
原创 Construct Special Binary Tree from given Inorder traversal
package tree;public class ConstructSpecialBinary { /** * Construct Special Binary Tree from given Inorder traversalGiven Inorder Traversal of a Special Binary Tree in which key of every node is
2014-07-01 11:09:27
381
原创 Vertical Sum in a given Binary Tree
package tree;import java.util.HashMap;import java.util.Set;public class VerticalSum { /** * Vertical Sum in a given Binary TreeGiven a Binary Tree, find vertical sum of the nodes that are in
2014-07-01 10:24:57
510
原创 Convert a given tree to its Sum Tree
package tree;class Ressum{ int sum;}public class ConvertagiventreetoitsSumTree { /** * Convert a given tree to its Sum TreeGiven a Binary Tree where each node has positive and negative values
2014-07-01 10:09:09
427
原创 Connect nodes at same level using constant extra space
Connect nodes at same level using constant extra space
2014-07-01 09:33:03
564
原创 Check if a given Binary Tree is SumTree
package tree;class Ress{int sum;}public class SumTree {/*** Following is an example of SumTree. 26 / \ 10 3 / \ \ 4 6
2014-06-30 21:35:24
434
原创 打印二叉树中某个节点的所有父节点
package tree;public class PrintAncestorsofagivenode { /** * 打印二叉树中某个节点的所有父节点 * @param args */ public static boolean printan(TreeNode root,int num){ if(root==null) return false; if(root.
2014-06-30 20:55:10
1111
原创 Get Level of a node in a Binary Tree
package tree;public class GetLevelofanode { /** * 求二叉树某个节点所在的层数,如果没有就返回0 * @param args */ public static int getlevel(TreeNode root,int num,int level){ if(root==null) return 0; if(root.v
2014-06-30 20:45:03
431
原创 打印二叉树中距离根节点为k的所有节点
package tree;public class Printnodesatkdistancefromroot { /** * Given a root of a tree, and an integer k. Print all * the nodes which are at k distance from root.For example, in the below t
2014-06-30 20:34:40
705
原创 Foldable Binary Trees
package tree;public class FoldableBinaryTrees { /** * Consider the below trees:(a) and (b) can be folded.(c) and (d) cannot be folded.(a) 10 / \ 7 15 \ /
2014-06-30 20:23:02
343
原创 求二叉树的宽度
package tree;import java.util.LinkedList;public class WithOfTree { /** * 求二叉树的宽度,其实就是层次遍历的改进 * @param args */ public static int getWith(TreeNode root){ if(root==null) return 0; Linked
2014-06-30 20:03:07
615
原创 DoubleTree
package tree;public class DoubleTree { /** * Write a program that converts a given tree to its Double tree. * To create Double tree of the given tree, create a new duplicate for each node,
2014-06-30 19:51:19
722
原创 根据前序和中序数组构造二叉树(递归方法)
package tree;public class ConstructTree { /** * 根据前序和中序数组构造二叉树 * @param args */ public static int idx = 0; public static TreeNode construct(int[] pre,int[] in, int left,int right){ if(l
2014-06-30 19:32:01
462
原创 查看一颗二叉树从根到叶子路径的节点和是否等于某个给定的数
package tree;public class Roottoeafpathsumequaltoagivennumber { /** * 查看一颗二叉树从根到叶子路径的节点和是否等于某个给定的数 * @param args */ public static boolean isexit(TreeNode root,int num,int sum){ if(root==n
2014-06-30 18:24:50
619
原创 不带栈的二叉树中序非递归遍历
package tree;public class InorderTree { /** * 不带栈的二叉树中序非递归遍历 * 1. Initialize current as root 2. While current is not NULL If current does not have left child a) Print current’s data
2014-06-30 17:39:34
486
原创 带栈的二叉树的非递归中序遍历
1 / \ 2 3 / \ 4 5package tree;import java.util.Stack;public class InorderTreeTraversal { /** * 带栈的二叉树的非递归中序遍历 * @param args */ public static
2014-06-30 17:08:45
537
原创 判断一颗二叉树是否平衡
package tree;class height{ int h;}public class Isbanabalanced { /** * 判断一颗二叉树是不是平衡的二叉树,本质是采用后序遍历 * @param args */ public static boolean isbalance(TreeNode root){ if(root==null) return
2014-06-30 16:56:42
446
原创 求解一颗二叉树中两个叶子节点最长的路径
package tree;class Res{ int max;}public class DiameterofaBinary { /** * 求解一颗二叉树中两个叶子节点最长的路径 * @param args */ public static int getDiameter(TreeNode root,Res rs){ if(root==null) return
2014-06-30 16:46:05
1582
原创 查看一颗二叉树的每个节点的值是否都是其左右两个孩子节点值的和
package tree;public class SumProperty { /** * 查看一颗二叉树的每个节点的值是否都是其左右两个孩子节点值的和 * 当有一个孩子节点为空时,节点值为0 * @param args */ public static boolean issumproperty(TreeNode root){ if(root==null||(roo
2014-06-30 12:51:30
926
原创 统计二叉树叶子节点的个数
package tree;public class CountleafNode { /** * 统计二叉树中叶子节点的个数 * @param args */ public static int count(TreeNode root){ if(root==null) return 0; int sum = 0; if(root.left==null&&root.r
2014-06-29 10:21:26
2987
原创 层次遍历二叉树
package tree;import java.util.LinkedList;public class LevelOrder { /** * 层次遍历二叉树 * @param args */ public static void levelorder(TreeNode root){ if(root==null) return; LinkedList list
2014-06-29 10:16:24
585
原创 打印二叉树从根节点到叶子节点的所有路径
package tree;import java.util.LinkedList;public class TreePath { /** * 打印二叉树从根节点到叶子节点的所有路径 * @param args */ public static void getPath(TreeNode root){ if(root==null) return; LinkedLis
2014-06-29 00:54:36
5766
原创 将一颗二叉树转换成它的镜像
package tree;public class MirrorTree { /** * 将一颗二叉树转换成它的镜像 * @param args */ public static void convertmirror(TreeNode root){ if(root==null||(root.left==null&&root.right==null)) return;
2014-06-29 00:39:22
820
原创 删除一颗二叉树
package tree;public class DeleteBT { /** * 删除一颗二叉树 * @param args */ public static TreeNode delete(TreeNode root){ if(root==null) return root; root.left = delete(root.left); root.right
2014-06-29 00:29:19
1059
原创 判断两颗二叉树是否相同
package tree;public class IsIdentical { /** * 判断两棵树是否相同 * @param args */ public boolean isidentical(TreeNode root1,TreeNode root2){ if(root1==null||root2==null){ if(root1!=null){ r
2014-06-29 00:14:28
634
原创 Prim最小生成树的最小堆的java代码实现
package prim;public class MinHeapNode { int v ; int weight ; public MinHeapNode( int v, int weight) { this .v = v; this .weight = weight;
2014-06-28 21:13:18
762
原创 Prim算法的简单实现
package prim;/** * 图的邻接矩阵实现的Prim算法 * @author Administrator * */public class Prim { public void getPrim(int[][] g,int v){ boolean mstset[] = new boolean[v]; int parent[] = new int[v]; i
2014-06-28 16:23:55
465
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人