
数据结构
newStrongBoy
这个作者很懒,什么都没留下…
展开
-
java写中缀表达式转后缀表达式,并将转换后的结果输出
public class TestStack { //判断是否为操作符 private static boolean isOperator(String oper){ if(oper.equals("+") || oper.equals("-") || oper.equals("/") || oper.equals("*") || oper.equals("(")...原创 2018-07-10 15:36:25 · 518 阅读 · 0 评论 -
java实现回溯算法-八皇后问题
/** * 回溯算法 * * 八皇后问题 * */public class Queen { public static int num = 0;//累计方案 public static final int MAXQUEEN = 8; public static int[] cols = new int[MAXQUEEN]; //定义数组,表示8列棋子皇后摆放...原创 2018-08-01 09:49:03 · 1084 阅读 · 1 评论 -
java实现动态规划-求两个字符串的最大子序列
/** * 动态规划 * * 求两个字符串的最大子序列 * */public class LCS { public int findLcs(String A,String B){ int n = A.length(); int m = B.length(); char[] a = A.toCharArray(); ...原创 2018-08-01 09:48:15 · 466 阅读 · 0 评论 -
java实现回溯算法-约瑟芬杀人法
/** * 回溯算法 * * 约瑟芬杀人问题 * */public class Josephus { private static int N = 20; private static int M = 5; //数到M就咔嚓一个人 class Node{ int val; //下标 Node next; ...原创 2018-08-01 09:47:30 · 1252 阅读 · 0 评论 -
java实现贪心算法-背包问题
//背包问题(贪心算法)public class GreedyPackage { private int MAX_WEIGHT = 150; private int[] weights = new int[]{35,30,60,50,40,10,25}; private int[] values = new int[]{10,40,30,50,35,40,30};...原创 2018-08-01 09:46:55 · 7051 阅读 · 6 评论 -
java实现-拓扑排序
import java.util.Stack;//拓扑排序public class GraphTopologic { private int numVertexes; private VertexNode[] adjList;//邻接顶点的一维数组 public GraphTopologic(int numVertexes){ this.numV...原创 2018-08-01 09:46:17 · 1647 阅读 · 0 评论 -
java实现-图的相关操作
import java.util.LinkedList;public class Graph { private int vertexSize;//顶点的数量 private int[] vertexs;//顶点数组 private int[][] matrix;//矩阵 private boolean[] isVisited;//是否访问过 priv...原创 2018-08-01 09:45:31 · 430 阅读 · 0 评论 -
java实现分治法-球队的赛程安排
//分治算法//球队的赛程安排public class Divide { public void scheduleTable(int[][] table,int n){ if(n == 1){ //球队数量 table[0][0] = 1; }else{ //填充左上区域 ...原创 2018-08-01 09:44:45 · 958 阅读 · 0 评论 -
java实现穷举法-泊松分酒
/** * 泊松分酒 * */public class ShareWine { private int b1 = 12; private int b2 = 8; private int b3 = 5; private int m = 6;//要分的酒量 private void backBottle(int bb1,int bb2,int bb3)...原创 2018-08-01 09:18:35 · 594 阅读 · 0 评论 -
java实现查找二叉树(BST)的相关操作
public class SearchTree { private TreeNode root; public TreeNode getRoot() { return root; } public void setRoot(TreeNode root) { this.root = root; } public ...原创 2018-08-01 08:47:51 · 239 阅读 · 0 评论 -
java实现迪杰斯特拉算法
public class Dijstra { private static final int MAXVEX = 9;//顶点数 private static final int MAXWEIGHT = 65535; private int[] shortTablePath = new int[MAXVEX]; //记录v0到某顶点的最短路径和 //获取一个图...原创 2018-07-27 10:01:44 · 807 阅读 · 0 评论 -
java实现分治法---棋盘覆盖问题
/** * 分治算法 * * 棋盘覆盖问题 * * 2 2 3 3 * 2 1 1 3 * 4 1 0 1 * 4 4 1 1 * */public class ChessBoradProblem { private int[][] board; //棋盘 private int specialRow; //特殊点的行下标 priv...原创 2018-07-27 09:21:57 · 1052 阅读 · 0 评论 -
java实现查找二叉树
public class SearchTree { private TreeNode root; public TreeNode getRoot() { return root; } public void setRoot(TreeNode root) { this.root = root; } public ...原创 2018-07-27 08:41:31 · 932 阅读 · 0 评论 -
用java实现二叉树的相关操作
public class TestTree { private TreeNode root = null; public TestTree(){ root = new TreeNode(1,"A"); } public TreeNode getRoot() { return root; } public v...原创 2018-07-26 11:17:15 · 192 阅读 · 0 评论 -
java实现基本的排序算法
/** * 排序的算法 * */public class TestSort { public static void main(String[] args) { TestSort t = new TestSort(); int[] array = new int[]{25, 341, 6, 121,1,99,4}; t.binary...原创 2018-08-01 11:57:26 · 241 阅读 · 0 评论