
算法
吴冬冬
此处省略300字
展开
-
正方形数量问题终极解答
废了不少脑细胞 public static int newsquareCount(int a , int b){ int k=a<b?a:b; return k*(k+1)*(2*k+1)/6+(Math.abs(a-b)*k*(k+1)/2); }原创 2016-04-01 15:01:54 · 5017 阅读 · 0 评论 -
手机客户端数据传输加密设计
登陆的时候进行一次双向非对称协议1.客户端先发起非对称请求2.服务端返回一次非对称响应3.在返回数据中用请求密钥及响应密钥返回在业务数据的加密中就可以使用对称密钥加密4.在业务数据请求是用请求密钥对称加密5.在业务数据响应时用响应密钥对称加密 非对称加密可以使用RSA,对称加密可使用DES 本文章属于原创,转载请注明出处。http://blog.youkuaiyun.com/lastsweetop/原创 2012-11-25 19:06:18 · 19115 阅读 · 5 评论 -
最小生成树Kruskal算法
数据结构使用不相交森林,复杂度 O(ElgV)package com.eshore.sweetop.mintree;import java.util.ArrayList;import java.util.Collections;import java.util.List;import com.eshore.sweetop.exdataframe.DisjointSetForest;public c原创 2008-12-09 10:43:00 · 1492 阅读 · 0 评论 -
图算法之强连通分支
package com.eshore.sweetop.mapbase;import java.awt.Color;import java.util.LinkedList;public class SCCTest { private static int time; public static void DFS(Graphics g,LinkedList list) { f原创 2008-12-05 15:08:00 · 1589 阅读 · 0 评论 -
Peterson算法实现线程互斥
package com.eshore.sweetop.os;public class Peterson { boolean[] interested=new boolean[2]; int turn; /** * @param process */ public void enter(int process){ int other;原创 2008-12-05 18:15:00 · 3216 阅读 · 0 评论 -
图算法之广度优先搜索
package com.eshore.sweetop.mapbase;import java.awt.Color;import java.util.LinkedList;import java.util.Queue;/** * Class GTest * @author wudongdong * GTest.java * Dec 4, 2008 */public class GTest {原创 2008-12-04 18:26:00 · 1388 阅读 · 0 评论 -
图算法之拓扑排序
/** * */package com.eshore.sweetop.mapbase;import java.awt.Color;import java.util.LinkedList;/** * Class TopoLogical * @author wudongdong * TopoLogical.java * Dec 5, 2008 */public class TopoLogic原创 2008-12-05 10:04:00 · 1368 阅读 · 0 评论 -
图算法之深度优先
/** * */package com.eshore.sweetop.mapbase;import java.awt.Color;/** * Class DFSTest * @author wudongdong * DFSTest.java * Dec 5, 2008 */public class DFSTest { private static int time; publ原创 2008-12-05 09:55:00 · 1372 阅读 · 0 评论 -
算法之不相交集合森林
package com.eshore.sweetop.exdataframe;public class DisjointSetForest { public void makeSet(DisjointSetNode node){ node.setParent(node); node.setRank(0); } public void l原创 2008-11-06 10:44:00 · 1678 阅读 · 0 评论 -
算法之斐波那契堆
package com.eshore.sweetop.exdataframe;/* * mark */public class FibHeap { private FibNode min; private int count; private FibNode root; public FibHeap() { root = new FibNode();原创 2008-11-04 11:00:00 · 1817 阅读 · 0 评论 -
算法之二项堆
package com.eshore.sweetop.exdataframe;public class BinomialHeap { private BinomialNode head; public BinomialNode getHead() { return head; } private void setHead(BinomialNode head)原创 2008-10-31 18:41:00 · 1916 阅读 · 4 评论 -
单源最短路径(二)————BellmanFord算法
package om.eshore.sweetop.minpath;public class BellmanFord extends Graphics { public BellmanFord(Vertex...vs){ for (Vertex v : vs) { list.add(v); } } @Overrid原创 2008-12-11 15:13:00 · 1427 阅读 · 0 评论 -
算法-----二次探查
package com.eshore.sweetop.dataframe;import java.math.BigInteger;import com.eshore.sweetop.data.KeyData;public class DoubleOpenHash extends OpenHash { public DoubleOpenHash(int size) {// super原创 2008-10-08 19:41:00 · 1447 阅读 · 0 评论 -
算法-----冒泡排序
package com.eshore.sweetop.sort;import java.util.Arrays;public class Bubble { public static void sort(int[] a,boolean reverse){ for (int i = 0; i 1; i++) { for (int j = i+1; j原创 2008-09-26 15:10:00 · 1327 阅读 · 0 评论 -
算法之二叉查找树
package com.eshore.sweetop.dataframe;import java.util.Random;import com.eshore.sweetop.data.KeyData;import com.eshore.sweetop.data.Node;/* * bintree */public class Bintree { private Node root;原创 2008-10-09 11:36:00 · 1204 阅读 · 0 评论 -
算法-----开放寻址法
packagecom.eshore.sweetop.dataframe;importcom.eshore.sweetop.data.KeyData;/**开放寻址法解决碰撞问题*/publicclassOpenHash{protectedKeyData[]table;publicOpenHash(intsize){table=newKeyD原创 2008-10-08 19:39:00 · 1997 阅读 · 0 评论 -
算法----乘法连接法散列表
package com.eshore.sweetop.dataframe;import java.util.LinkedList;import com.eshore.sweetop.data.KeyData;public class MultiChainedHash { LinkedList[] table = new LinkedList[(int)Math.pow(2, 6)];原创 2008-10-08 14:55:00 · 1394 阅读 · 0 评论 -
算法之不相交集合链表
package com.eshore.sweetop.exdataframe;public class DisjointSetLink { private DisjointElement head; private DisjointElement tail; public void makeSet(DisjointElement element){ head原创 2008-11-06 10:42:00 · 1350 阅读 · 0 评论 -
单源最短路径(四)————Dijkstra算法
package om.eshore.sweetop.minpath;public class Dijkstra extends Graphics { Dijkstra(Vertex...vs){ int index=0; for (Vertex v : vs) { list.add(v); v.setIndex(inde原创 2008-12-11 20:14:00 · 1435 阅读 · 0 评论 -
单源最短路径(三)————Dag实现
package om.eshore.sweetop.minpath;import java.awt.Color;import java.util.LinkedList;public class Dag extends Graphics { private int time = 0; public Dag(Vertex... vs) { for (Vertex v : vs原创 2008-12-11 16:37:00 · 1689 阅读 · 0 评论 -
单源最短路径(一)————松弛技术
package om.eshore.sweetop.minpath;import java.util.ArrayList;import java.util.List;public abstract class Graphics{ protected List list=new ArrayList(); public void initSingleSource(Vertex v)原创 2008-12-11 15:08:00 · 2185 阅读 · 0 评论 -
算法-----堆排序
package com.eshore.sweetop.sort;import java.util.Arrays;public class Heap { private static int parent(int i) { return (i-1) >> 1; } private static int left(int i) { return i 1|1原创 2008-09-26 15:51:00 · 1174 阅读 · 0 评论 -
算法之B树
package com.eshore.sweetop.exdataframe;public class BTree { private BNode root; private int min; public BTree() { BNode node = new BNode(); node.setLeaf(true); node.setCo原创 2008-10-31 13:44:00 · 1580 阅读 · 0 评论 -
算法之带权调度问题(有个人新创复杂度n算法)
package com.eshore.sweetop.cupidity;import java.util.ArrayList;import java.util.List;public class Quest { Qt[] qt = { new Qt(4, 70), new Qt(2, 60), new Qt(4, 50), new Qt(3, 40), new Qt(1原创 2008-10-29 19:03:00 · 1527 阅读 · 0 评论 -
算法之活动选择问题
//递归版本 public void recursive(){ activitySelector(s,f,-1,a.length-1); } public void activitySelector(int[] s, int[] f, int i, int n) { int m = i + 1; while (m 1?0:原创 2008-10-28 11:30:00 · 1350 阅读 · 0 评论 -
算法-----链接法散列表
package com.eshore.sweetop.dataframe;import java.util.LinkedList;import com.eshore.sweetop.data.KeyData;public class ChainedHash { LinkedList[] table = new LinkedList[10]; public void insert(KeyData o原创 2008-10-07 16:39:00 · 1385 阅读 · 0 评论 -
算法-----队列
package com.eshore.sweetop.dataframe;public class Quene { private int head=-1; private int tail=0; private int[] q; public Quene(){ q=new int[100]; } public Quene(int原创 2008-10-07 16:35:00 · 1039 阅读 · 0 评论 -
算法-----计数排序
package com.eshore.sweetop.sort;import java.util.Arrays;public class Count { public static int[] sort(int a[]){ int[] b=new int[a.length]; //100是基数,可以处理100以下的排序,根据实际情况调整原创 2008-09-27 11:52:00 · 1395 阅读 · 0 评论 -
算法-----堆结构实现优先级队列
package com.eshore.sweetop.dataframe;import java.util.Arrays;public class MaxHeapQeuen { private static int parent(int i) { return (i - 1) >> 1; } private stati原创 2008-09-26 17:00:00 · 1224 阅读 · 0 评论 -
算法-----前言
最近用到很多算法的问题,才发现有些东西忘了就此机会好好打下基础。代码我会一一发出,和大家共同学习。原创 2008-09-26 15:05:00 · 1330 阅读 · 0 评论 -
算法-----线性顺序统计
package com.eshore.sweetop.orderstatistic;import java.util.Random;public class RandomSelect { private static Random rd = new Random(47); public static int select(int[] a, int i) { return原创 2008-09-29 18:10:00 · 1150 阅读 · 0 评论 -
算法-----基数排序
package com.eshore.sweetop.sort;import java.util.Arrays;public class Radix { public static int[] sort(int[] a,int d){ int[] b=new int[a.length]; for (int i = 0; i原创 2008-09-29 15:34:00 · 1237 阅读 · 0 评论 -
算法-----快速排序
package com.eshore.sweetop.sort;import java.util.Arrays;public class Quick { private static int partition(int[] a, int p, int r) { int x = a[r]; int i = p - 1;原创 2008-09-26 19:18:00 · 1295 阅读 · 0 评论 -
算法-----插入排序
package com.eshore.sweetop.sort;import java.util.Arrays;public class Insertion { public static void sort(int[] a,boolean reverse){ int key=0,i=0; for(int j=1;j原创 2008-09-26 15:12:00 · 1310 阅读 · 0 评论 -
算法-----随即快速排序
package com.eshore.sweetop.sort;import java.util.Arrays;import java.util.Random;public class RandomQuick { private static Random rd = new Random(47); private static int randomPartition(int[] a,i原创 2008-09-27 10:25:00 · 1374 阅读 · 0 评论 -
算法-----链表
package com.eshore.sweetop.dataframe;public class MyLinkedList { private Element head; public void insert(int x){ Element e=new Element(x); e.next=head; if(head!=null){原创 2008-10-07 16:36:00 · 1040 阅读 · 0 评论 -
算法之红黑树
package com.eshore.sweetop.dataframe;import com.eshore.sweetop.data.KeyData;import com.eshore.sweetop.data.Node;import com.eshore.sweetop.data.RBNode;public class RBTree { private RBNode root; p原创 2008-10-10 13:57:00 · 1416 阅读 · 1 评论 -
算法之动态顺序统计
package com.eshore.sweetop.dataframe;import com.eshore.sweetop.data.KeyData;import com.eshore.sweetop.data.Node;import com.eshore.sweetop.data.RBNode;public class RBTree { private RBNode root; p原创 2008-10-13 20:14:00 · 1424 阅读 · 0 评论 -
算法之赫夫曼编码
package com.eshore.sweetop.cupidity;import java.util.ArrayList;public class Huffman { private char[] c = { a, b, c, d, e, f }; private int[] f={45,13,12,16,9,5}; class Node{原创 2008-10-28 15:18:00 · 1615 阅读 · 0 评论 -
算法之双重散列
package com.eshore.sweetop.dataframe;import java.math.BigInteger;import com.eshore.sweetop.data.KeyData;public class DoubleOpenHash extends OpenHash { public DoubleOpenHash(int size) {// super原创 2008-10-08 19:42:00 · 2048 阅读 · 0 评论