- 博客(8)
- 收藏
- 关注
原创 贪心算法求单源最短路径
public class TheShortestWay {static int MAX_SIZE=6;public static void dijkstra(int v,float[][]a,float[]dist,int[]prev){ int n=dist.length-1; if(vn)return; boolean []s=new boolean[n...
2009-11-16 14:26:16
289
原创 回溯法求八皇后问题
package javaapplication5;/** * * @author Administrator */import java.util.*;public class Queens { // squares per row or column public static final int BOARD_SIZE = 8; //...
2009-11-16 14:19:39
113
原创 贪心算法求解背包问题
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package chapter02;import java.util.Arrays;import java.util.LinkedList;public class A...
2009-11-02 13:42:12
173
原创 0-1背包问题
/** * */ package com.zyf; /** * @author zyf 题目:给定n个物体,其中第i个物体重量wi,价值vi ,另有一个最大载重W的背包,往里面塞东西使得总价值尽可能大 * * 令f(i,j)表示用前i个物体装出重量为j的组合时的最大价值 * f(i,j)=max{f(i-...
2009-10-26 13:43:35
93
原创 最长公共子序列
public class LCSProblem { public static void main(String[] args) { String[] x = {"", "A", "B", "C", "B", "D", "A", "B"}; String[] y
2009-10-19 13:39:45
90
原创 大整数相乘
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.math.*;public class Test1 { public static void main(String[] args){ Test1...
2009-10-12 12:45:06
100
原创 快速排序
快速排序[b]关键字: 数据结构[/b] package com.liuyu.array; public class Point{ public static void main(String[] args) { int[] a = {4,63,2,4,4,6,43,2,3}; quickSort(a, 0, a.length - 1);...
2009-10-02 15:50:31
83
原创 归并排序
归并排序[b]关键字: 数据结构[/b] package com.liuyu.array; public class MergeSort { public int[] sort(int[] data) { int[] temp = new int[data.length]; mergeSort(data, temp, 0, data.length - 1); retur...
2009-10-02 15:49:45
92
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人