在STL中,排序是个很重要的话题。1.algorithm 里的sort()只接收RandomAccessIterator用于像vector,dequeue的排序2.像set,map,这种关联式容器,本身就由RBTree维护了有序,只要遍历一遍就行了。3.而list比较特殊一点,由于只有Bidirec...
分类:
其他好文 时间:
2014-06-28 22:09:39
阅读次数:
209
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord...
分类:
其他好文 时间:
2014-06-28 19:23:45
阅读次数:
200
几种树:(1)平衡树:package com.jp.algorithm.tree;import java.util.Iterator;import java.util.NoSuchElementException;/** * 平衡二叉树 * * 定义:首先它是一种特殊的二叉排序树,其次它的左子树和....
分类:
其他好文 时间:
2014-06-28 17:14:17
阅读次数:
156
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
分类:
其他好文 时间:
2014-06-28 15:14:05
阅读次数:
194
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexi...
分类:
其他好文 时间:
2014-06-20 23:34:47
阅读次数:
308
算法定义 最大期望算法(Exception Maximization Algorithm,后文简称EM算法)是一种启发式的迭代算法,用于实现用样本对含有隐变量的模型的参数做极大似然估计。已知的概率模型内部存在隐含的变量,导致了不能直接用极大似然法来估计参数,EM算法就是通过迭代逼近的方式用实际的.....
分类:
其他好文 时间:
2014-06-20 17:39:58
阅读次数:
215
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr...
分类:
其他好文 时间:
2014-06-20 15:29:46
阅读次数:
233
对于很多应用来说,随机算法是最简单的或者最快的。既简单又快的有没有呢?
那需要深刻的洞察力或者革命性的突破。
什么是随机算法
随机算法与确定算法区别是:它还接收输入随机比特流来做随机决策。
对于同一个输入,每次运行所用的算法行为都不同,虽然结果都是一样的。
Foiling an adversary
可以构造一个输入使得一个确定性算法运行时间最长。
随机算法可以看作是从...
分类:
编程语言 时间:
2014-06-18 07:37:02
阅读次数:
240
堆是一种完全二叉树结构,并且其满足一种性质:父节点存储值大于(或小于)其孩子节点存储值,分别称为大顶堆、小顶堆。堆一般采用数组进行存储(从下标为0开始)。则父节点位置为i,那么其左孩子为2*i + 1,右孩子为2*i + 2。一. 算法描述 堆排序主要分为两个过程:建堆:先使长度为N数组形成一...
分类:
其他好文 时间:
2014-06-18 00:08:54
阅读次数:
207
3DES是继DES容易被破解后的DES加密升级版,它属于对称加密。可指定24位长度的密钥,在java API中也有其实现,代码如下:
/**
* 3DES 的Java SDK API 实现
* @author dxd
* 201406917
*/
public class DES3 {
private static final String Algorithm = "DESede";/...
分类:
其他好文 时间:
2014-06-17 18:57:36
阅读次数:
187