
数据结构
数据结构笔记
Simon
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
AVLTreeDemo
package com.atguigu.avl; public class AVLTreeDemo { public static void main(String[] args) { //int[] arr = {4,3,6,5,7,8}; //int[] arr = { 10, 12, 8, 9, 7, 6 }; int[] arr = { 10, 11, 7, 6, 8, 9 }; //创建一个 AVLTree对象原创 2020-08-06 23:10:58 · 117 阅读 · 0 评论 -
BinarySortTreeDemo
package com.atguigu.binarysorttree; public class BinarySortTreeDemo { public static void main(String[] args) { int[] arr = {7, 3, 10, 12, 5, 1, 9, 2}; BinarySortTree binarySortTree = new BinarySortTree(); //循环的添加结点到二叉排序树原创 2020-08-06 23:10:28 · 128 阅读 · 0 评论 -
堆排序
package com.atguigu.tree; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; public class HeapSort { public static void main(String[] args) { //要求将数组进行升序排序 //int arr[] = {4, 6, 8, 5, 9}; // 创建要给原创 2020-08-01 23:04:00 · 109 阅读 · 0 评论 -
赫夫曼树
package com.atguigu.tree; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class HuffmanTree { public static void main(String[] args) { int arr[] = { 13, 7, 8, 3, 29, 6, 1 }; Node root = createHu原创 2020-08-01 23:03:19 · 147 阅读 · 0 评论 -
二叉树前序中序后序遍历查找删除
package com.atguigu.tree; public class BinaryTreeDemo { public static void main(String[] args) { //先需要创建一颗二叉树 BinaryTree binaryTree = new BinaryTree(); //创建需要的结点 HeroNode root = new HeroNode(1, "宋江"); HeroNode node2 = n原创 2020-07-31 16:22:12 · 124 阅读 · 0 评论 -
HashTabDemo
package com.atguigu.hashtab; import java.util.Scanner; public class HashTabDemo { public static void main(String[] args) { //创建哈希表 HashTab hashTab = new HashTab(7); //写一个简单的菜单 String key = ""; Scanner scanne转载 2020-07-28 23:38:14 · 107 阅读 · 0 评论 -
二分查找+插值查找
二分查找 package com.atguigu.search; import java.util.ArrayList; import java.util.List; public class BinarySearch { public static void main(String[] args) { int arr[] = { 1, 8, 10, 89,1000,1000, 1234 }; //int arr[] = { 1, 2, 3, 4, 5, 6, 7原创 2020-07-26 22:33:52 · 180 阅读 · 0 评论 -
基数排序
package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; public class RadixSort { public static void main(String[] args) { int arr[] = { 53, 3, 542, 748, 14, 214}; // 80000000 * 11原创 2020-07-26 21:44:56 · 170 阅读 · 0 评论 -
归并排序
package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Date; public class MergeSort { public static void main(String[] args) { //int arr[] = { 8, 4, 5, 7, 1, 3, 6, 2 }; // //测试快排的执行速度 // 创建要给80000个的随机的数原创 2020-07-26 19:36:47 · 101 阅读 · 0 评论 -
快速排序
package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Date; public class QuickSort { public static void main(String[] args) { //int[] arr = {-9,7777,777,555,78,0,23,1,8888,111,154,-567,70, -1,900, 4561}; //测试快原创 2020-07-25 23:04:34 · 85 阅读 · 0 评论 -
希尔排序
package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; public class ShellSort { public static void main(String[] args) { //int[] arr = { 8, 9, 1, 7, 2, 3, 5, 4, 6, 0 }; // 创建要给80000个的随机的数组原创 2020-07-24 22:23:41 · 88 阅读 · 0 评论 -
插入排序
插入排序 package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Date; public class InsertSort { public static void main(String[] args) { int[] arr = new int[80000]; for (int i = 0; i < 80000; i++) { a原创 2020-07-24 21:19:27 · 85 阅读 · 0 评论 -
选择排序
选择排序 package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Date; public class SelectSort { public static void main(String[] args) { //创建要给80000个的随机的数组 int[] arr = new int[80000]; for (int i = 0; i <原创 2020-07-23 23:31:00 · 91 阅读 · 0 评论 -
冒泡排序
冒泡排序 package com.atguigu.sort; import java.text.SimpleDateFormat; import java.util.Date; public class BubbleSort { public static void main(String[] args) { //测试一下冒泡排序的速度O(n^2), 给80000个数据,测试 //创建要给80000个的随机的数组 int[] arr = new i原创 2020-07-23 23:13:22 · 99 阅读 · 0 评论 -
递归回溯、迷宫及八皇后问题
打印与阶乘问题 package com.atguigu.recursion; public class recursionTest { public static void main(String[] args) { test(4); int n=factorial(3); System.out.println(n); } //打印问题 public static void test(int n){ if(n原创 2020-07-23 21:03:02 · 114 阅读 · 0 评论 -
逆波兰计算器与中缀表达式转后缀表达式
package com.atguigu.stack; import java.util.ArrayList; import java.util.List; import java.util.Stack; public class PolandNotation { public static void main(String[] args) { //先定义一个逆波兰表达式 //(30+4)*5-6 => 30 4 + 5 * 6 - => 164原创 2020-07-20 20:52:14 · 127 阅读 · 0 评论 -
数组模拟栈与链表模拟栈
1 用数组模拟栈结构 package com.atguigu.stack; //用数组模拟栈 import java.util.Scanner; public class ArrayStackDemo { public static void main(String[] args) { //测试一下ArrayStack是否正确 ArrayStack stack = new ArrayStack(4); String key="";原创 2020-07-20 20:12:11 · 109 阅读 · 0 评论 -
栈实现综合计算器
栈实现综合计算器(中缀) package com.atguigu.stack; public class Calculator { public static void main(String[] args) { String expression="3+700*6-2"; //创建两个栈一个数栈一个符号栈 ArrayStack2 numberStack = new ArrayStack2(10); ArrayStack2 operS原创 2020-07-20 20:06:26 · 190 阅读 · 0 评论 -
链表题
//将单链表反转 public static void reverseList(HeroNode head){ //传入的是链表的头节点 //如果链表为空或者只有一个节点,就直接返回 if(head.next==null||head.next.next==null){ return;` } HeroNode reverseHead=new HeroNode(0,"",""); HeroNod..原创 2020-07-14 15:45:20 · 113 阅读 · 0 评论 -
环形链表-约瑟夫问题
public class Josephu { public static void main(String[] args) { //测试一下看看添加小孩和显示 CircleSingleLinkedList circleSingleLinkedList = new CircleSingleLinkedList(); circleSingleLinkedList.addBoy(5); circleSingleLinkedList.show.原创 2020-07-14 15:25:17 · 172 阅读 · 0 评论