有多种最短路径的应用场景,它们需要用到不同的算法来解决。除了贪心最优搜索之外,其他都是最优性算法,即得到的解都是最短路径。其中m是边的数量,n是点的数量。问题边权算法时间复杂度一个起点,一个终点非负数;无边权(或边权为1)A*算法
算法随笔:强连通分量
bughunter-
#算法随笔算法数据结构图论强连通分量KosarajuTarjan
概念和性质:强连通:在有向图G中,如果两个点u和v是互相可达的,即从u出发可以到达v,从v出发也可以到达u,则成u和v是强连通的。强连通分量:如果一个有向图G不是强连通图,那么可以把它分成躲个子图,其中每个子图的内部是强连通的,而且这些子图已经扩展到最大,不能与子图外的任一点强连通,成这样的一个“极大连通”子图是G的一个强连通分量(SCC)。强连通分量的一些性质:(1)一个点必须有出度和入度,才会
算法随笔:Floyd
bughunter-
#算法随笔算法数据结构图论最短路多源最短路Floyd传递闭包问题
Floyd算法是一种对所有点对最短路径算法、多源最短路径算法,以此计算能得到图中每一对节点之间的最短路径。Floyd不仅可以用来求多源最短路,也可以用于解决传递闭包问题。算法思想:Floyd求最短路径用的是“从小图到全图”的动态规划思想,定义状态dp[k][i][j],i、j、k都为节点编号,范围为1~n。状态dp[k][i][j]表示在包含1~k点的子图上,点对i、j的最短路径。当从子图1~k-
算法随笔:点双连通分量&边双连通分量
bughunter-
#算法随笔算法数据结构图论
点双连通分量概念及性质:在一个连通图中任选两点,如果它们之间至少存在两条“点不重复”的路径,则称为点双连通分量。在这个图上去掉任意一个点,整个图仍然连通。即点双连通分量中不存在割点。不同的点双连通分量最多只有一个公共点,即某个割点;任意割点都是至少两个点双连通分量的公共点。在一个无向图中求点双连通分量数量的方法:容易发现,在找到一个割点时,已经完成了一次对某个极大点双连通子图的访问。那么我们在DF
算法随笔:关于树的一些常见基本问题总结
bughunter-
#算法随笔算法数据结构
1、判断一个图是否为树判断步骤有向图(转换为有根图)无向图(转换为无根图)找树根计算出每个节点的入边和出边数量。树根是只有出边没有入边的点。基于有向图的树只是一个树根,如果找不到树根,或者找到了多个树根,说明这不是一棵树。任何节点都可以当作树根。检查父子关系从根开始DFS遍历图,要求每个点都得被访问一次,且只能访问一次,这代表每个节点只有一个父节点。相同检查连通性在DFS的过程中,检查是否所有的点
算法随笔:图论问题之割点割边
bughunter-
#算法随笔算法数据结构
割点定义割点的定义:如果一个点被删除之后会导致整个图不再是一个连通图,那么这个顶点就是这个图的割点。举例:上图中的点2就是一个割点,如果它被删除,则整个图被分为两个连通分量,不再是一个连通图。求割点的方法最直观容易想到的一种简单朴素的方法:依次删除每一个顶点,然后用dfs或者bfs来检查图是否依然连通。如果删除某个顶点后,导致图不再连通,那么刚才删除的顶点就是割点。这种方法的时间复杂度是O(N(N
【算法·算法随笔】(大整数运算)大整数的进制转换问题万能解法,含codeup练习讲解(1950 problem b进制转换、1952 problem f 10进制vs2进制)
亿维数组
算法算法c语言开发语言数据结构c++
《算法笔记》中,对于大整数的运算,给出了最基础的几个算法模板,包括大整数的结构体、输出、与字符串的转换,以及四则预算(不包含高精度与高精度的乘除)。但是在codeup训练当中,又出现了两种经典问题,第一是对大浮点数的处理,第二是对于大整数的进制转换问题,下面对于大整数的进制转换问题,说一种万能超级解法。codeup相关题型对应标号为:(看完文章就可以试试)直接在csdn搜也可以搜到原题1950-P
【算法·算法随笔】(大整数运算)大浮点数问题的总结
亿维数组
算法算法数据结构c语言c++
《算法笔记》中,对于大整数的运算,给出了最基础的几个算法模板,包括大整数的结构体、输出、与字符串的转换,以及四则预算(不包含高精度与高精度的乘除)。但是在codeup训练当中,又出现了两种经典问题,第一是对大浮点数的处理,第二是对于大整数的进制转换问题。这篇文章主要讲解大浮点数的加减运算。codeup相关题型对应标号为:(看完文章就可以试试)直接在csdn搜也可以搜到原题1922-Problem-
算法随笔:快速排序的思想及实现分析
会飞的佳灿
核心代码如下:intpartition(inta[],intleft,intright){srand((unsigned)time(NULL));intp=(round(1.0*rand()/RAND_MAX*(right-left))+left);//选择轴元素swap(a[left],a[p]);inttemp=a[left];//将轴元素存放至临时变量tempwhile(lefttemp)r
liujing
安心岁月
最好的年纪最好的自己博客园首页新随笔联系订阅管理随笔-50文章-0评论-1十大经典算法随笔-29文章-9评论-305十大经典排序算法(动图演示)0、算法概述0.1算法分类十种常见排序算法可以分为两大类:非线性时间比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破O(nlogn),因此称为非线性时间比较类排序。线性时间非比较类排序:不通过比较来决定元素间的相对次序,它可以突破基于比
lj十大经典算法
安心岁月
最好的年纪最好的自己博客园首页新随笔联系订阅管理随笔-50文章-0评论-1十大经典算法随笔-29文章-9评论-305十大经典排序算法(动图演示)0、算法概述0.1算法分类十种常见排序算法可以分为两大类:非线性时间比较类排序:通过比较来决定元素间的相对次序,由于其时间复杂度不能突破O(nlogn),因此称为非线性时间比较类排序。线性时间非比较类排序:不通过比较来决定元素间的相对次序,它可以突破基于比
数据结构与算法随笔之优先队列-求滑动窗口最大值(三)
杨辉
优先队列数据结构与算法java
这篇文章我们来看一道题目求滑动窗口最大值问题(在leetcode上的地址:滑动窗口最大值)题目描述给定一个长度为N的数组nums,有一个大小为k的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口k内的数字。滑动窗口每次只向右移动一位。返回滑动窗口最大值。示例:输入:nums=[1,3,-1,-3,5,3,6,7],和k=3输出:[3,3,5,5,6,7]解决方案一、使用最大堆来实现
【算法随笔】最小生成树
dianpaoqian9249
最小生成树(MST):[洛谷模版传送门]一个有n个结点的连通图的生成树是原图的极小连通子图,且包含原图中的所有n个结点,并且有保持图连通的最少的边。——度娘百度百科说白了就是给你一个图,把边权等都给你(特殊情况是相等的)。然后让这些节点全部都连成一颗树,问最小的代价是多少。本篇blog会对kruskal算法进行详细讲解。其实是Prim掌握还不熟kruskal算法是用的比较多的一类求最小生成树的算法
数据结构与算法随笔之------最长回文子串四种方法求解(暴力枚举+动态规划+中心扩展+manacher算法(马拉车))
markconca的博客
数据结构与算法随笔
所谓回文串,就是正着读和倒着读结果都一样的回文字符串。比如:a,aba,abccba都是回文串,ab,abb,abca都不是回文串。一、暴力法方法一:直接暴力枚举求每一个子串时间复杂度O(N^2),判断子串是不是回文O(N),两者是相乘关系,所以时间复杂度为O(N^3)。#includeusingnamespacestd;stringlongestPalindrome(string&s){intl
算法随笔-替换字符串中的子串
火焰山大白菜
算法随笔
在我们的项目里,经常会将字符串中的指定的内容替换为我们需要的内容,这里我们就来实现这这个小算法。具体需求则为:将字符串中的指定子串替换为设置的字符串,并返回替换的总数,实现比较简单,主要是指针的运算,下边直接代码展示:#include#include#includeintStrRepalce(char*nSrc,constchar*oldStr,constchar*newStr){if(!nSrc
数据结构与算法随笔之------二分查找(一文彻底搞懂二分)
markconca的博客
数据结构与算法随笔
一.二分法的基础内容二分查找也称折半查找(BinarySearch),它是一种效率较高的查找方法。但是,折半查找要求线性表必须采用顺序存储结构,而且表中元素按关键字有序排列。本文会介绍二分查找的基础内容以及最重要的在实际应用时二分法的各种变种及其套路,相信你看了本文,二分应该就ok了查找过程首先,假设表中元素是按升序排列,将表中间位置记录的关键字与查找关键字比较,如果两者相等,则查找成功;否则利用
加密算法随笔(ios)
Da_Hao
加密算法随笔(ios)一、加密原则:1、不能在网络传输过程中明文传输2、本地保存用户信息不能明文保存二、加密算法1、RSA非对称加密:私钥加密,公钥解密秘钥是个Key:就是一个数字,需要通过因式分解来破解现在的计算机破解需要50年2、哈希函数散列函数-MD5-SHA1-SHA256/5123、对称加密-DES-3DES-AES(高级密码标准,美国国家安全局使用的,iOS内部使用的也是这个),理论破
数据结构与算法随笔之------堆与优先队列详解
markconca的博客
数据结构与算法随笔
堆与优先队列1.定义优先队列队列是一个操作受限的线性表,数据只能在一端进入,另一端出来,具有先进先出的性质。有时在队列中需要处理优先级的情况,即后面进入的数据需要提前出来,这里就需要优先队列。优先队列是至少能够提供插入和删除最小值这两种操作的数据结构。对应于队列的操作,插入相当于入队,删除最小相当于出队。链表,二叉查找树,都可以提供插入和删除最小这两种操作。对于链表的实现,插入需要O(1),删除最
数据结构与算法随笔之链表-反转单向链表(一)
weixin_34326558
最近在学习数据结构和算法,目前学习到链表,这里主要分析下关于链表涉及的面试题解决思路和实现代码,本人熟悉java,所以实现都使用java。废话不多说请看第一题:反转单向链表(在leetcode上的题目地址:反转链表)题目描述:给定一个单项链表:A--->B--->C--->D--->E---null,编写一个函数反转这个单项链表,输出:E--->D---C--->B--->A--->null。算法
算法随笔
weixin_30919429
A=【1,2,3,5,8,7,6,5,9,1,1,6,9,8】B=【5,8,7】在A中找出B,元素必须是连续的(也就是在A中找出连在一起的5,8,7),返回符合这种情况的B的第一个元素在A的位置(也就是5的位置,第3位),如果没有,返回一个负数;条件:不允许用现有方法,正则。letA=[1,2,3,5,8,7,6,5,9,1,1,6,9,8];letB=[5,8,7];leta=A.toStrin
算法随笔 --- Manacher算法
Cake_Bunny_General
今天做leetcode看到了用O(n)时间复杂度来解决最大回文字符串的算法,马拉车算法,就搜索了一下,自己理解了之后把这个算法写在博客上。Manacher算法Manacher算法的应用范围狭窄,但是它的思想和拓展kmp算法有很多共通点。Manacher算法是查找一个字符串的最长回文子串的线性算法。计算字符串的最长回文字串最简单的算法就是枚举该字符串的每一个子串,并且判断这个子串是否为回文串,这个算
算法随笔
JAVA觅音阁
Prime//判断是否为素数publicbooleanisPrime(longnum){for(inti=2;iqueenCount){sum++;//可行方案数+1System.out.println("可行方案"+(index++)+"↓");output(feasible);System.out.println("------------------------------");}//t小于
算法随笔-二叉树遍历的N种姿势
msp的昌伟哥哥
最近在练习用Python刷算法,leetcode上刷了快300题。一开始怀疑自己根本不会写代码,现在觉得会写一点点了,痛苦又充实的刷题历程。对我这种半路出家的人而言,收获真的很大。今天就从二叉树遍历写起,曾经有次面试就被迭代实现卡过。。。最简单的递归#先序遍历defpreorderTraversal(self,root:TreeNode)->List[int]:res=[]defpreTraver
《算法设计与分析》--动态规划算法随笔
袁家小少爷
算法动态规划分治算法
1、动态规划算法的定义其实道理上来说动态规划算法和分治法是相类似的,其实都是将基本待求解的问题分解成若干个子问题,先求解子问题,然后再从这些子问题中得到原问题的解。与分治法的不同点在于使用动态规划求解的这类问题的子问题往往不是互相独立的,若果是使用分治法解这类问题,则分解得到的子问题数目太多。2、比较分析我们在使用分治法求解时,有些子问题已经被重复计算了许多次。要是我们提前可以保存已经解决的子问题
jquery实现的jsonp掉java后台
知了ing
javajsonpjquery
什么是JSONP?
先说说JSONP是怎么产生的:
其实网上关于JSONP的讲解有很多,但却千篇一律,而且云里雾里,对于很多刚接触的人来讲理解起来有些困难,小可不才,试着用自己的方式来阐释一下这个问题,看看是否有帮助。
1、一个众所周知的问题,Ajax直接请求普通文件存在跨域无权限访问的问题,甭管你是静态页面、动态网页、web服务、WCF,只要是跨域请求,一律不准;
2、
Struts2学习笔记
caoyong
struts2
SSH : Spring + Struts2 + Hibernate
三层架构(表示层,业务逻辑层,数据访问层) MVC模式 (Model View Controller)
分层原则:单向依赖,接口耦合
1、Struts2 = Struts + Webwork
2、搭建struts2开发环境
a>、到www.apac
SpringMVC学习之后台往前台传值方法
满城风雨近重阳
springMVC
springMVC控制器往前台传值的方法有以下几种:
1.ModelAndView
通过往ModelAndView中存放viewName:目标地址和attribute参数来实现传参:
ModelAndView mv=new ModelAndView();
mv.setViewName="success
WebService存在的必要性?
一炮送你回车库
webservice
做Java的经常在选择Webservice框架上徘徊很久,Axis Xfire Axis2 CXF ,他们只有一个功能,发布HTTP服务然后用XML做数据传输。
是的,他们就做了两个功能,发布一个http服务让客户端或者浏览器连接,接收xml参数并发送xml结果。
当在不同的平台间传输数据时,就需要一个都能解析的数据格式。
但是为什么要使用xml呢?不能使json或者其他通用数据
js年份下拉框
3213213333332132
java web ee
<div id="divValue">test...</div>测试
//年份
<select id="year"></select>
<script type="text/javascript">
window.onload =
简单链式调用的实现技术
归来朝歌
方法调用链式反应编程思想
在编程中,我们可以经常遇到这样一种场景:一个实例不断调用它自身的方法,像一条链条一样进行调用
这样的调用你可能在Ajax中,在页面中添加标签:
$("<p>").append($("<span>").text(list[i].name)).appendTo("#result");
也可能在HQ
JAVA调用.net 发布的webservice 接口
darkranger
webservice
/**
* @Title: callInvoke
* @Description: TODO(调用接口公共方法)
* @param @param url 地址
* @param @param method 方法
* @param @param pama 参数
* @param @return
* @param @throws BusinessException
Javascript模糊查找 | 第一章 循环不能不重视。
aijuans
Way
最近受我的朋友委托用js+HTML做一个像手册一样的程序,里面要有可展开的大纲,模糊查找等功能。我这个人说实在的懒,本来是不愿意的,但想起了父亲以前教我要给朋友搞好关系,再加上这也可以巩固自己的js技术,于是就开始开发这个程序,没想到却出了点小问题,我做的查找只能绝对查找。具体的js代码如下:
function search(){
var arr=new Array("my
狼和羊,该怎么抉择
atongyeye
工作
狼和羊,该怎么抉择
在做一个链家的小项目,只有我和另外一个同事两个人负责,各负责一部分接口,我的接口写完,并全部测联调试通过。所以工作就剩下一下细枝末节的,工作就轻松很多。每天会帮另一个同事测试一些功能点,协助他完成一些业务型不强的工作。
今天早上到公司没多久,领导就在QQ上给我发信息,让我多协助同事测试,让我积极主动些,有点责任心等等,我听了这话,心里面立马凉半截,首先一个领导轻易说
读取android系统的联系人拨号
百合不是茶
androidsqlite数据库内容提供者系统服务的使用
联系人的姓名和号码是保存在不同的表中,不要一下子把号码查询来,我开始就是把姓名和电话同时查询出来的,导致系统非常的慢
关键代码:
1, 使用javabean操作存储读取到的数据
package com.example.bean;
/**
*
* @author Admini
ORACLE自定义异常
bijian1013
数据库自定义异常
实例:
CREATE OR REPLACE PROCEDURE test_Exception
(
ParameterA IN varchar2,
ParameterB IN varchar2,
ErrorCode OUT varchar2 --返回值,错误编码
)
AS
/*以下是一些变量的定义*/
V1 NUMBER;
V2 nvarc
查看端号使用情况
征客丶
windows
一、查看端口
在windows命令行窗口下执行:
>netstat -aon|findstr "8080"
显示结果:
TCP 127.0.0.1:80 0.0.0.0:0 &
【Spark二十】运行Spark Streaming的NetworkWordCount实例
bit1129
wordcount
Spark Streaming简介
NetworkWordCount代码
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Struts2 与 SpringMVC的比较
BlueSkator
struts2spring mvc
1. 机制:spring mvc的入口是servlet,而struts2是filter,这样就导致了二者的机制不同。 2. 性能:spring会稍微比struts快。spring mvc是基于方法的设计,而sturts是基于类,每次发一次请求都会实例一个action,每个action都会被注入属性,而spring基于方法,粒度更细,但要小心把握像在servlet控制数据一样。spring
Hibernate在更新时,是可以不用session的update方法的(转帖)
BreakingBad
Hibernateupdate
地址:http://blog.csdn.net/plpblue/article/details/9304459
public void synDevNameWithItil()
{Session session = null;Transaction tr = null;try{session = HibernateUtil.getSession();tr = session.beginTran
读《研磨设计模式》-代码笔记-观察者模式
bylijinnan
java设计模式
声明: 本文只为方便我个人查阅和理解,详细的分析以及源代码请移步 原作者的博客http://chjavach.iteye.com/
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
/**
* “观
重置MySQL密码
chenhbc
mysql重置密码忘记密码
如果你也像我这么健忘,把MySQL的密码搞忘记了,经过下面几个步骤就可以重置了(以Windows为例,Linux/Unix类似):
1、关闭MySQL服务
2、打开CMD,进入MySQL安装目录的bin目录下,以跳过权限检查的方式启动MySQL
mysqld --skip-grant-tables
3、新开一个CMD窗口,进入MySQL
mysql -uroot
 
再谈系统论,控制论和信息论
comsci
设计模式生物能源企业应用领域模型
再谈系统论,控制论和信息论
偶然看
oracle moving window size与 AWR retention period关系
daizj
oracle
转自: http://tomszrp.itpub.net/post/11835/494147
晚上在做11gR1的一个awrrpt报告时,顺便想调整一下AWR snapshot的保留时间,结果遇到了ORA-13541这样的错误.下面是这个问题的发生和解决过程.
SQL> select * from v$version;
BANNER
-------------------
Python版B树
dieslrae
python
话说以前的树都用java写的,最近发现python有点生疏了,于是用python写了个B树实现,B树在索引领域用得还是蛮多了,如果没记错mysql的默认索引好像就是B树...
首先是数据实体对象,很简单,只存放key,value
class Entity(object):
'''数据实体'''
def __init__(self,key,value)
C语言冒泡排序
dcj3sjt126com
算法
代码示例:
# include <stdio.h>
//冒泡排序
void sort(int * a, int len)
{
int i, j, t;
for (i=0; i<len-1; i++)
{
for (j=0; j<len-1-i; j++)
{
if (a[j] > a[j+1]) // >表示升序
自定义导航栏样式
dcj3sjt126com
自定义
-(void)setupAppAppearance
{
[[UILabel appearance] setFont:[UIFont fontWithName:@"FZLTHK—GBK1-0" size:20]];
[UIButton appearance].titleLabel.font =[UIFont fontWithName:@"FZLTH
11.性能优化-优化-JVM参数总结
frank1234
jvm参数性能优化
1.堆
-Xms --初始堆大小
-Xmx --最大堆大小
-Xmn --新生代大小
-Xss --线程栈大小
-XX:PermSize --永久代初始大小
-XX:MaxPermSize --永久代最大值
-XX:SurvivorRatio --新生代和suvivor比例,默认为8
-XX:TargetSurvivorRatio --survivor可使用
nginx日志分割 for linux
HarborChung
nginxlinux脚本
nginx日志分割 for linux 默认情况下,nginx是不分割访问日志的,久而久之,网站的日志文件将会越来越大,占用空间不说,如果有问题要查看网站的日志的话,庞大的文件也将很难打开,于是便有了下面的脚本 使用方法,先将以下脚本保存为 cutlog.sh,放在/root 目录下,然后给予此脚本执行的权限
复制代码代码如下:
chmo
Spring4新特性——泛型限定式依赖注入
jinnianshilongnian
springspring4泛型式依赖注入
Spring4新特性——泛型限定式依赖注入
Spring4新特性——核心容器的其他改进
Spring4新特性——Web开发的增强
Spring4新特性——集成Bean Validation 1.1(JSR-349)到SpringMVC
Spring4新特性——Groovy Bean定义DSL
Spring4新特性——更好的Java泛型操作API
Spring4新
centOS安装GCC和G++
liuxihope
centosgcc
Centos支持yum安装,安装软件一般格式为yum install .......,注意安装时要先成为root用户。
按照这个思路,我想安装过程如下:
安装gcc:yum install gcc
安装g++: yum install g++
实际操作过程发现,只能有gcc安装成功,而g++安装失败,提示g++ command not found。上网查了一下,正确安装应该
第13章 Ajax进阶(上)
onestopweb
Ajax
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/
How to determine BusinessObjects service pack and fix pack
blueoxygen
BO
http://bukhantsov.org/2011/08/how-to-determine-businessobjects-service-pack-and-fix-pack/
The table below is helpful. Reference
BOE XI 3.x
12.0.0.
y BOE XI 3.0 12.0.
x.
y BO
Oracle里的自增字段设置
tomcat_oracle
oracle
大家都知道吧,这很坑,尤其是用惯了mysql里的自增字段设置,结果oracle里面没有的。oh,no 我用的是12c版本的,它有一个新特性,可以这样设置自增序列,在创建表是,把id设置为自增序列
create table t
(
id number generated by default as identity (start with 1 increment b
Spring Security(01)——初体验
yang_winnie
springSecurity
Spring Security(01)——初体验
博客分类: spring Security
Spring Security入门安全认证
首先我们为Spring Security专门建立一个Spring的配置文件,该文件就专门用来作为Spring Security的配置