上一页 1 2 3 4 5 6 ··· 34 下一页
摘要: import java.util.HashSet; /** * 判断一个链表是否有环,并找到入环的第一个节点 */ public class CircularLinkedList { public static void main(String[] args) { Node node1 = new 阅读全文
posted @ 2021-10-18 20:14 code-G 阅读(67) 评论(0) 推荐(0) 编辑
摘要: import java.util.Stack; /** * 判断一个链表是不是回文数 */ public class Palindrome { public static void main(String[] args) { Node node1 = new Node(1); Node node2 阅读全文
posted @ 2021-10-17 21:21 code-G 阅读(41) 评论(0) 推荐(0) 编辑
摘要: /** * 桶排序 */ public class BucketSort { public static void main(String[] args) { int[] array = {23,14,47,71,32}; int digit = digit(array); bucketSort(a 阅读全文
posted @ 2021-10-16 20:48 code-G 阅读(32) 评论(0) 推荐(0) 编辑
摘要: import java.util.PriorityQueue; /** * 一个几乎有序的数组,任意一个元素移动到有序位置 * 需要移动的距离小于等于K */ public class K_DistanceSort { public static void main(String[] args) { 阅读全文
posted @ 2021-10-16 20:32 code-G 阅读(84) 评论(0) 推荐(0) 编辑
摘要: public class HeapSort { public static void main(String[] args) { int[] array = {3,4,7,1,2}; heapSort(array); for (int i : array) { System.out.println( 阅读全文
posted @ 2021-10-16 20:25 code-G 阅读(35) 评论(0) 推荐(0) 编辑
摘要: /** * 快速排序3.0 * 1.0和2.0版本的时间复杂度都是O(N^2) * 3.0版本时间复杂度是O(NlogN) */ public class QuickSort3 { public static void main(String[] args) { int[] array = {3,1 阅读全文
posted @ 2021-10-14 00:05 code-G 阅读(249) 评论(0) 推荐(0) 编辑
摘要: /** * 快速排序2.0 * 在1.0的基础上将最右侧数的一组放在中间,左侧都比其小,右侧都比其大 */ public class QuickSort2 { public static void main(String[] args) { int[] array = {3,1,2,4,5,3,5} 阅读全文
posted @ 2021-10-14 00:02 code-G 阅读(112) 评论(0) 推荐(0) 编辑
摘要: /** * 快速排序1.0 * 以最右边的数为基准分开数组 * 分开后将最右边的数与比起刚大一点的数交换 * 再将左右两侧递归使用上述方法(去最右侧为基准...) */ public class QuickSort1 { public static void main(String[] args) 阅读全文
posted @ 2021-10-14 00:00 code-G 阅读(102) 评论(0) 推荐(0) 编辑
摘要: public class MergeSort { public static void main(String[] args) { int[] array = {3,2,4,1,5}; Sort(array, 0, array.length - 1); for (int i : array) { S 阅读全文
posted @ 2021-10-13 21:12 code-G 阅读(27) 评论(0) 推荐(0) 编辑
摘要: /** * 求一个数组的最大值 */ public class Recursive { public static void main(String[] args) { int[] array = {3,2,4,1,5}; System.out.println(RecursiveMax(array, 阅读全文
posted @ 2021-10-13 18:32 code-G 阅读(60) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 34 下一页