
数据结构
#眼镜&
我从未想过输,除非我不想赢。
展开
-
数据结构 线索化二叉树
HeroNode rootpublic class ClurBinaryTree { private HeroNode root; //当前节点前驱结点指针 private HeroNode pre=null; public void setRoot(HeroNode root) { this.root = root; } /** * xiansuohuaerchashu */ public void clueN原创 2022-01-17 16:57:56 · 224 阅读 · 0 评论 -
数据结构 顺序存储二叉树
public class ArrayBinaryTree { private int[] arrays; public ArrayBinaryTree(int[] arrays) { this.arrays = arrays; } /** * 前序遍历顺序存储二叉树 */ public void preSelect(int index){ if(this.arrays==null||arrays.length==.原创 2022-01-17 14:00:45 · 356 阅读 · 0 评论 -
数据结构 树(二叉树)实现实例
文章目录树的常用术语二叉树满二叉树前序遍历中序遍历后序遍历顺序存储二叉树在一维数组中的存储特特点实现实例配图运行结果class Nodeclass BinaryTree树的常用术语二叉树满二叉树前序遍历中序遍历后序遍历顺序存储二叉树在一维数组中的存储特特点实现实例配图运行结果class Nodepublic class Node { private int no; private String name; private Node left;原创 2022-01-15 19:24:05 · 1042 阅读 · 0 评论 -
数据结构 哈希表 (散列表)实现实例 数组与链表的结合使用
文章目录哈希表用图了解哈希表实现案例实现思想class Studentclass StudentLInkedListclass HashTable哈希表用图了解哈希表实现案例实现思想注意数组中存储的数据类型为StudentLinkedListclass Studentpublic class Student { public int id; public String name; public Student next; public Student原创 2022-01-13 15:47:03 · 652 阅读 · 0 评论 -
数据结构 黄金分割法算法(斐波那切数列)
文章目录黄金分割图解class FibonacciSelect黄金分割图解class FibonacciSelectimport java.util.Arrays;public class FibonacciSelect { public static void main(String[] args) { int[] arrays={1,1,2,3,5,8,13,21,34,55,89}; System.out.println(select(arrays,原创 2022-01-12 20:29:53 · 211 阅读 · 0 评论 -
数据结构 插值查找 实现实例
文章目录插值查找插值查找mid计算方法class InsertLook插值查找插值查找mid计算方法class InsertLookpublic class InsertLook { public static void main(String[] args) { int [] arrays= new int[]{1,2,3,4,5,6,7,8,9}; int left=0; int right= arrays.length-1;原创 2022-01-12 19:15:45 · 110 阅读 · 0 评论 -
数据结构 二分查找(折半查找) 实现实例
文章目录二分查找用图来了解二分查找(折半查找)class ZheBanLook二分查找用图来了解二分查找(折半查找)class ZheBanLookpublic class ZheBanLook { public static void main(String[] args) { int [] arrays= new int[]{0,1,2,3,4,5,6,7,8,9,10}; int i = zheBanLook(arrays, 0, arrays.l原创 2022-01-12 16:11:23 · 477 阅读 · 0 评论 -
数据结构 线性查找 实现实例
文章目录class LineLook运行结果class LineLookpublic class LineLook { public static void main(String[] args) { int[] arrays= new int[]{1,2,3,4,5,6,7,8,9,0}; int i = lineLook(arrays, 9); System.out.println(i); } public static int原创 2022-01-12 15:16:21 · 160 阅读 · 0 评论 -
数据结构 关于递归的自我感悟
文章目录自我总结赋予案列一个自我总结有句话这样说“人可以理解循环,神可以理解递归”这么说也不无道理,因为递归的确有一定的难度。但是,也不是说他是不可以逾越的。他就像珠穆朗玛峰,看着似乎似天堑,但是只要我们努力总是可以攀登到山顶的,只不过是时间的问题。什么是递归就一句话,就是一个方法自己调用自己;或者说是一个函数自己调用自己要想搞懂递归我认为明白以下几点尤为重要第一点:每当你是使用递归时要明白,你使用递归要做什么;第二点:一定要找准递归的结束条件是什么;第三点:一定要找准什么时候开始使用递归原创 2022-01-12 14:55:16 · 684 阅读 · 0 评论 -
数据结构 归并排序 实现实例
文章目录用图了解归并排序class Msort用图了解归并排序class Msortimport java.util.Arrays;public class Msort { public static void main(String[] args) { int[] arrays= new int[]{1,4,2,3,7,6,5,9,8,0}; //临时数组 int[] temp=new int[arrays.length];原创 2022-01-12 14:34:30 · 244 阅读 · 0 评论 -
数据结构 希尔排序 实现实例
文章目录希尔排序用图了解希尔排序class xiErSort希尔排序用图了解希尔排序class xiErSortimport java.util.Arrays;public class xiErSort { public static void main(String[] args) { //准备数据 int[] arrays= new int[]{2,1,3,5,4,7,6,8,9,0}; //确定排序的次数 for原创 2022-01-11 15:56:11 · 213 阅读 · 0 评论 -
数据结构 选择排序 实现实例
文章目录选择排序用图了解选择排序class selectSort运行结果选择排序用图了解选择排序class selectSortimport java.util.Arrays;public class selectSort { public static void main(String[] args) { int[] arrays=new int[]{2,3,1,4,5,7,6,8}; //用来获取每次要比较的数据 for (int原创 2022-01-11 13:59:21 · 77 阅读 · 0 评论 -
数据结构 插入排序 实现实例
文章目录图示了解插入排序运行结果图示了解插入排序import java.util.Arrays;public class InsertSort { public static void main(String[] args) { int[] arrays= new int[]{2,1,3,4,5,6,8,7}; //拿取要比较的数据 for(int i=1;i< arrays.length;i++) {原创 2022-01-11 13:27:51 · 181 阅读 · 0 评论 -
数据结构 快速排序 实现实例 HMCXY
文章目录图解快速排序图解快速排序import java.util.Arrays;import java.util.Random;public class DemoQuickSort { public static void main(String[] args) {/* //定义数组 int[] arrays={6,3,7,9,5,1,4,8}; //调用方法,进行快速排序 quickSort(arrays,0, arr原创 2022-01-10 22:26:59 · 258 阅读 · 0 评论 -
数据结构 快速排序 实现实例DLJD
文章目录快速排序快速排序import java.util.Arrays;public class QuickSort { public static void main(String[] args) { int [] arrays= new int[]{2,9,4,7,3,3,6,5}; sort(arrays,0, arrays.length-1); System.out.println(Arrays.toString(arrays));原创 2022-01-10 20:35:21 · 184 阅读 · 0 评论 -
数据结构 基数排序 实现实例
文章目录基数排序介绍基数排序思想基数排序示例class BasicSort运行结果总结知识点基数排序介绍基数排序思想基数排序示例class BasicSortimport java.util.Arrays;public class BasicSort { public static void main(String[] args) { int [] arrays= new int[]{53,542,3,63,14,214,154,748,616};原创 2022-01-10 16:18:38 · 476 阅读 · 0 评论 -
数据结构 时间复杂度
文章目录时间频度时间频度忽略常数项时间频度忽略低次项时间频度忽略次数时间复杂度常见的时间复杂度平均时间复杂度和最坏时间复杂度常见算法的时间复杂度时间频度时间频度忽略常数项时间频度忽略低次项时间频度忽略次数时间复杂度常见的时间复杂度平均时间复杂度和最坏时间复杂度常见算法的时间复杂度...原创 2022-01-10 14:22:01 · 72 阅读 · 0 评论 -
数据结构 递归 小球走迷宫的问题
文章目录实现要求class MazeApp执行结果实现要求class MazeApppublic class MazeApp { public static void main(String[] args) { int[][] map = new int[8][7]; /** * 设置第一行和最后一行为墙,设置为1 */ for(int i=0;i<7;i++){ map原创 2022-01-10 00:06:48 · 126 阅读 · 0 评论 -
数据结构 队列 数组实现
文章目录了解队列class ArrayQueueclass TestApp了解队列class ArrayQueuepublic class ArrayQueue { //用数组来实现队列 private int[] array; //通过maxSize来指定队列的大小 //通过maxSize我们可以自由实现数组大小的控制 private int maxSize; //队首指针 private int frontPoint; //队尾指针原创 2022-01-09 22:48:27 · 87 阅读 · 0 评论 -
数据结构 稀疏数组链表实现 稀疏数组的还原
文章目录执行要求执行效果图class SparseValueclass LinkeListSparseArrayclass SparseLinkedList执行要求执行效果图class SparseValuepublic class SparseValue { private int x; private int y; private int value; private SparseValue next; public SparseValue() {原创 2022-01-09 21:40:24 · 276 阅读 · 0 评论 -
数据结构 稀疏数组和稀疏数组的还原
文章目录了解什么是稀疏数组class SparseArray执行效果图了解什么是稀疏数组class SparseArraypublic class SparseArray { public static void main(String[] args) { /** * 1.模拟出棋盘数据使用二维数组(五子棋) */ int[][] array=new int[11][11]; array[1][2]=1;原创 2022-01-08 22:25:51 · 251 阅读 · 0 评论 -
数据结构 单向循环链表 约瑟夫问题
文章目录约瑟夫问题class Boyclass CircleSingleLinkedListclass CircleSingleLinkedListTest约瑟夫问题class Boypublic class Boy { //节点编号 private int no; //指向下一个节点 private Boy next; public Boy(int no) { this.no = no; } public void s原创 2022-01-08 20:53:49 · 658 阅读 · 0 评论 -
数据结构 双向链表的相关操作
文章目录class BookNodeclass DualLinkedListclass DualLinkedListTestclass BookNodepublic class BookNode { public int id; public String name; public double price; //节点下一个节点 直接后继 public BookNode next; //上一个节点 直接前驱 public BookNode pre;原创 2022-01-08 12:04:00 · 424 阅读 · 0 评论 -
数据结构 线性结构与非线性结构
我们常听闻的数据结构有栈,队列,链表,图,树等。其中栈,队列,链表是线性结构的。而图,树,等是非线性的,线性结构中的栈和队列是通过数组来实现的。再为一个数组开辟空间时,我们需要为其开辟一个连续的空间,也就是内存地址要连续。对于链表我们为其开辟的空间可以是不连续的,链表的思想更接近于面向对象的思想。...原创 2022-01-07 21:48:10 · 446 阅读 · 0 评论 -
数据结构 单向链表的相关操作
文章目录class GoodsNodeclass DLLinkedListclass LinkedTestclass GoodsNodepublic class GoodsNode { public int id; public String name; public double price; public GoodsNode next; public GoodsNode() { } public GoodsNode(int id, Stri原创 2022-01-07 21:15:51 · 98 阅读 · 0 评论 -
数据结构 用数组模拟栈 回纹字符串
public class ArrayStack { //数组的大小 private int mayStack; //模拟栈的数组 private int[] stack; //指向栈顶的指针 private int top=-1; public ArrayStack(int mayStack){ this.mayStack=mayStack; stack= new int[mayStack];//数组在使用时我们必须先初原创 2022-01-02 15:33:39 · 243 阅读 · 0 评论 -
Java 平衡二叉树的结构图
原创 2021-11-29 11:29:49 · 266 阅读 · 0 评论 -
顺序表的基本操作
顺序表的顺序存储#include <stdio.h>#include <conio.h>//主要用来处理一些人为的输入输出操作#define MAX 30 //定义线性表的最大长度enum BOOL{False,True}; //定义BOOL型,判断类型只用来判断返回值的真假,Bool类型只有TRUE和FALSE两种状态typedef struct{ char elem[MAX]; //线性表 int last; //原创 2021-11-28 22:48:24 · 225 阅读 · 0 评论 -
Java 二分查找
public class Check { public static void main(String[] args) { int[] arry=new int[]{12,13,14,15,17,18,19,100}; int index= erFenChaoZhao(arry,100); System.out.println(index==-1?"要查找的元素不存在":"要查找的元素的小标为"+index); } private s原创 2021-11-22 15:57:25 · 100 阅读 · 0 评论 -
Java 选择排序
import java.util.Arrays;import java.util.Scanner;public class Test { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length= scanner.nextInt(); int[] arry = new int[length]; for(原创 2021-11-22 14:27:57 · 229 阅读 · 0 评论 -
Java 冒泡排序
import java.util.Arrays;import java.util.Scanner;public class Test { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length= scanner.nextInt(); int[] arry = new int[length]; for(原创 2021-11-22 12:20:47 · 73 阅读 · 0 评论 -
结构体与结构体指针
# include<stdio.h>typedef struct student { int id;}stu;int jiaohuan(stu a);int main(void){ stu a; int b; scanf_s("%d", &a.id); b=jiaohuan(a); printf("%d", b); return 0;}int jiaohuan(stu a){ a.id = 10; return(a.id);}运行结果配图#in原创 2021-06-07 12:38:26 · 136 阅读 · 0 评论 -
线性表的顺序表示及基本操作
//--------------------------顺序表的存储结构--------------------------#define MAXSIZE 100 //顺序表可能达到的最大长度typedef struct{ Elemtype *elem; //存储空间的基地址 int length; //当前长度 }SqList; //顺序表的结构类型SqList(俗称结构名为SqList)//----------------------多项原创 2020-12-07 18:24:46 · 234 阅读 · 0 评论 -
数据结构(算法 数组逆序)
算法 一空间复杂度为O(n)# include<stdio.h>int main (void){ int n,i; scanf("%d",&n); int a[n],b[n]; for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) b[i]=a[n-i-1]; for(i=0;i<n;i++) a[i]=b[i]; for(i=0;i<n;i++) printf("%原创 2020-11-23 16:28:15 · 472 阅读 · 0 评论 -
数据结构 (和最大子序列 算法)
题目描述对于一个给定的长度为N的整数序列A,它的“子序列”的定义是:A中非空的一段连续的元素(整数)。你要完成的任务是,在所有可能的子序列中,找到一个子序列,该子序列中所有元素的和是最大的(跟其他所有子序列相比)。程序要求你输出这个最大值。输入输入文件的第一行包含一个整数N,第二行包含N个整数,表示A。其中1<=N<=100000-10000<=A[i]<=10000输出输出仅包含一个整数,表示你算出的答案。样例输入 Copy53 -2 3 -5 4样例输出原创 2020-11-23 15:10:38 · 174 阅读 · 0 评论 -
数据结构 (矩阵的乘积算法)
n阶矩阵相乘# include<stdio.h>int main(){ int n,i,j,k; scanf("%d",&n); int a[n][n],b[n][n],c[n][n]; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { scanf("%d",&a[i][j]); } } for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { sca原创 2020-11-22 19:21:13 · 1487 阅读 · 0 评论 -
数据结构 (抽象数据类型的定义:以复数为例)
# include<stdio.h>#include<iostream>#include <iomanip>using namespace std;# include<stdlib.h>typedef struct{ float Realpart;//实部 float Imagepart;//虚部}Complex;void Create (Complex &C,float x,float y);//创建复数float GetReal原创 2020-11-22 16:50:14 · 4023 阅读 · 0 评论 -
数据结构1.1-
一级目录三种基本的数据结构类型1.线性的数据结构类型:元素之间存在简单的一对一的线性关系2.树状的数据结构类型:元素之间存在一对多的层次关系3.图状的数据结构类型:元素之间存在多对多的网状关系程序设计的实质...原创 2020-11-11 17:33:20 · 124 阅读 · 0 评论 -
奖学金合集(结构体)
题目描述某校发放奖学金共5种,获取条件各不同:1.阳明奖学金,每人8000,期末平均成绩>80,且在本学期发表论文大于等于1篇;2.梨洲奖学金,每人4000,期末平均成绩>85,且班级评议成绩>80;3.成绩优秀奖,每人2000,期末平均成绩>90;4.西部奖学金,每人1000,期末平均成绩>85的西部省份学生;5.班级贡献奖,每人850,班级评议成绩>80的学生干部。只要符合条件就可以得奖,一人可兼得多项奖学金。例:某生,期末平均成绩87,班级评议成绩82原创 2020-11-02 22:09:46 · 704 阅读 · 0 评论 -
数字去重(结构体)
题目描述一天,小明坐在院子里数星星,Gardon就出了个难题给她:Gardon在天空画出了一个矩形区域,让他输入矩形区域里有多少颗星星,仁慈的上帝还为他标出了每个星星的坐标。但小明数着数着就看花了眼,但他的原则是:宁愿多数一次,不可错过一个。如果小明把他数过的星星的坐标都告诉你,你能否帮他进行排重处理(如果两个星星的坐标位置相同,则视为一个星星),计算出星星的个数。输入首先输入一个整数n(n<=300),接下来的n对整数,每对表示小明数过的一个星星的位置(星星的坐标在-10000到10000之间原创 2020-10-31 15:39:55 · 337 阅读 · 0 评论