
数据结构
Serendipity_ry
邮箱:ry_abc@163.com
展开
-
十大经典排序算法总结及实现(java)
Java算法总结二分查找冒泡排序插入排序快速排序希尔排序归并排序桶排序基数排序剪枝算法 二分查找 又叫折半查找,要求待查找的序列有序。每次取中间位置的值与待查关键字比较,如果中间位置的值比待查关键字大,则在前半部分循环这个查找的过程,如果中间位置的值比待查关键字小,则在后半部分循环这个查找的过程。直到查找到了为止,否则序列中没有待查的关键字。 public static int biSearch(int []array,int a){ int lo=0; int hi=array.length-1;原创 2020-07-26 09:27:10 · 181 阅读 · 0 评论 -
java数据结构----图的实现
java数据结构----图的实现 图的实现这里用邻接矩阵。 代码: 定义邻接矩阵: static final int MaxNum=20; //图的最大顶点数 static final int MaxValue=65535; //最大值 class GraphMaterix{ int GType; //图的类型(0:无向图 1:有向图) int VertexNum;//顶点数量 int EdgeNum; //边的数量 char[] Vert原创 2020-07-25 09:51:06 · 145 阅读 · 0 评论 -
java数据结构----二叉树的实现
java数据结构----二叉树的实现 代码实现: 定义节点: public class Node { private int data; private Node leftChild; private Node rightChild; public void setRightChild(Node rightChild) { this.rightChild = rightChild; } public void setLeftChild(N原创 2020-07-25 09:31:04 · 115 阅读 · 0 评论 -
java数据结构----循环队列的实现
java数据结构----循环队列的实现 代码实现: public class CycleQueue { private int[] array; private int elements; private int front; private int end; public CycleQueue() { array=new int[10]; elements=0; front=0; end=-1;原创 2020-07-25 09:26:39 · 87 阅读 · 0 评论 -
java数据结构----队列的实现
java数据结构----队列的实现 这篇博客讲最简单的队列实现代码,如果需要循环队列的实现,请查看下一篇博客。 代码实现: public class Queue { private int[] array; private int elements; private int front; private int end; public Queue() { array=new int[10]; elements=0;原创 2020-07-25 09:24:27 · 87 阅读 · 0 评论