算法与数据结构
偷生.
这个作者很懒,什么都没留下…
展开
-
分治算法解决汉诺塔移动问题
class DivideAndConquer package Algorithm; /** * 分治算法解决汉诺塔移动问题 * @author coffee * @Date 2021-04-06 10:18 */ public class DivideAndConquer { public static void main(String[] args) { hanoiTower(2,'A','B','C'); } public static void .原创 2021-04-06 17:28:28 · 101 阅读 · 0 评论 -
二分查找法的非递归实现
class BinarySearchNoRecur package Algorithm; /** * 二分查找法的非递归实现 * 数组必须是升序 * @author coffee * @Date 2021-04-05 17:35 */ public class BinarySearchNoRecur { public static void main(String[] args) { int[] arr = {1,3,8,10,11,67,100}; .原创 2021-04-05 17:48:54 · 59 阅读 · 0 评论 -
图与其DFS、BFS
class Graph package DataStructures.graph; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; /** * 图与其DFS、BFS * @author coffee * @Date 2021-04-05 15:14 */ public class Graph { public static void main(String[] ar.原创 2021-04-05 17:29:45 · 76 阅读 · 0 评论 -
平衡二叉树(AVL树)
class SelfBalancingBinarySearchTree package DataStructures.tree; /** * 平衡二叉树(AVL树) * @author coffee * @Date 2021-04-05 12:28 */ public class SelfBalancingBinarySearchTree { public static void main(String[] args) { int[] arr = {4,3,6,5,7,.原创 2021-04-05 15:01:16 · 67 阅读 · 1 评论 -
二叉排序树(BST)
class BinarySortTree package DataStructures.tree; /** * 二叉排序树(BST) * @author coffee * @Date 2021-04-04 18:43 */ public class BinarySortTree { public static void main(String[] args) { int[] arr = {7,3,10,12,5,1,9,2}; BinarySortTr.原创 2021-04-05 15:00:25 · 95 阅读 · 1 评论 -
线索化二叉树
class ThreadedBinaryTree package DataStructures.tree; /** * 线索化二叉树 * @author coffee * @Date 2021-04-04 12:02 */ public class ThreadedBinaryTree { public static void main(String[] args) { } private HeroNode2 root; private HeroNode.原创 2021-04-05 14:59:39 · 97 阅读 · 1 评论 -
二叉树
class BinaryTree package DataStructures.tree; /** * 二叉树 * @author coffee * @Date 2021-04-03 15:25 */ public class BinaryTree { public static void main(String[] args) { BinaryTree binaryTree = new BinaryTree(); HeroNode root = ne.原创 2021-04-05 14:58:53 · 227 阅读 · 0 评论 -
哈夫曼树
class HuffmanTree package DataStructures.tree; import java.util.ArrayList; import java.util.Collections; /** * 赫夫曼树 * @author coffee * @Date 2021-04-04 15:05 */ public class HuffmanTree { public static void main(String[] args) { int[] a.原创 2021-04-05 14:57:58 · 85 阅读 · 1 评论 -
遍历顺序存储二叉树
class ArrBinaryTree package DataStructures.tree; /** * 遍历顺序存储二叉树 * @author coffee * @Date 2021-04-03 16:48 */ public class ArrBinaryTree { private int[] arr; public ArrBinaryTree(int[] arr){ this.arr = arr; } public void .原创 2021-04-05 14:56:40 · 71 阅读 · 0 评论 -
堆排序
class HeapSort package DataStructures.sort; import java.util.Arrays; /** * 堆排序 * @author coffee * @Date 2021-04-04 12:51 */ public class HeapSort { public static void main(String[] args) { int[] arr = {4,6,8,5,9}; heapSort(arr).原创 2021-04-04 14:55:19 · 52 阅读 · 0 评论 -
代码实现哈希表
class HashTable package DataStructures.hashTable; /** * @author coffee * @Date 2021-04-03 12:40 */ public class HashTable { EmpLinkedList[] empLinkedLists; int size; public HashTable(int size) { this.size = size; empLink.原创 2021-04-04 12:00:13 · 323 阅读 · 0 评论 -
查找算法
二分查找 package DataStructures.search; import java.util.ArrayList; /** * 二分查找 * 要求数组必须有序 * @author coffee * @Date 2021-04-03 10:20 */ public class BinarySearch { public static void main(String[] args) { int[] arr ={1, 8, 10, 89, 1000, 10.原创 2021-04-04 11:59:50 · 49 阅读 · 1 评论 -
7种排序算法
冒泡排序 package DataStructures.sort; import java.util.Arrays; /** * 冒泡排序 * @author coffee * @Date 2021-04-01 13:53 */ public class BubbleSort { public static void main(String[] args) { int[] arr = {3,9,-1,10,-2}; bubbleSort(arr); .原创 2021-04-04 11:59:27 · 70 阅读 · 0 评论 -
八皇后问题
class Queen package DataStructures.recursion; /** * @author coffee * @Date 2021-03-31 15:23 */ public class Queen { int max = 8;//有8个皇后 int[] array = new int[max];//保存皇后位置的结果 static int count = 0; public static void main(String[] ar.原创 2021-04-03 20:19:46 · 53 阅读 · 0 评论 -
递归解决迷宫问题
class Maze package DataStructures.recursion; /** * @author coffee * @date 2021-03-31 14:45 */ public class Maze { public static void main(String[] args) { int[][] ints = new int[8][7]; //使用1表示墙,上下全部设置为1 for (int i = 0; i &.原创 2021-04-03 20:18:06 · 90 阅读 · 0 评论 -
逆波兰表达式做计算器
PolandNotation.java package DataStructures.stack; import java.util.ArrayList; import java.util.List; import java.util.Stack; /** * 中缀表达式转为后缀表达式 * 逆波兰表达式做计算器 * @author coffee * @date 2021-03-30 21:45 */ public class PolandNotation { public sta.原创 2021-04-03 20:16:19 · 63 阅读 · 0 评论 -
用数组模拟栈实现简单计算器的功能
class Calculator package DataStructures.stack; import org.junit.jupiter.api.Test; /** * 简单计算器 * @author coffee * @date 2021-03-30 17:28 */ public class Calculator { @Test public void test(){ String expression = "3+6*2-2+1"; .原创 2021-04-03 20:14:29 · 66 阅读 · 0 评论 -
用数组实现栈
class arrStack package DataStructures.stack; /** * 用数组模拟栈 * @author coffee * @date 2021-03-30 17:00 */ public class arrStack { private int maxSize; private int[] stack; private int top = -1; public arrStack(int maxSize) { th.原创 2021-04-03 20:12:15 · 69 阅读 · 0 评论 -
约瑟夫问题
JosephuProblem.java package DataStructures.linkedList; /** 约瑟夫问题 * 构建一个环形链表思想: * 1.先创建第一个节点,让first指针指向该节点,并形成环状 * 2.每当我们创建一个新的节点,就把该节点加入到已有的环形链表中 * 遍历环形链表 * 1.让一个指针指向first节点 * 2.然后通过while循环遍历即可 * 3.该指针.next == first结束 * * @author coff.原创 2021-04-03 20:10:40 · 57 阅读 · 3 评论 -
单链表创建、遍历、插入、修改
HeroNode.class package DataStructures.linkedList; /** * @author coffee * @date 2021-03-29 17:13 */ public class HeroNode { public int no; public String name; public String nickName; public HeroNode next; public HeroNode(int no, S.原创 2021-04-03 20:03:49 · 104 阅读 · 0 评论 -
数组模拟队列
ArrayQueue.class package DataStructures.queue; /** * @author coffee * @date 2021-03-29 15:55 */ public class ArrayQueue { private int maxSize;//队列最大容量 private int front; //头 private int rear;//尾 private int[] arr;//模拟队列的数组 public A原创 2021-04-03 19:59:59 · 43 阅读 · 0 评论 -
稀疏数组与二维数组互相转换
package DataStructures.sparseArray; import java.io.*; /** * @author coffee * @date 2021-03-29 13:53 */ public class arrayAndSparseTransformEachOther{ public static void main(String[] args) { //创建一个原始的11*11的二维数组,0表示没有棋子,1表示黑子,2表示蓝子原创 2021-04-03 19:57:22 · 79 阅读 · 0 评论