![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
okrensky888
这个作者很懒,什么都没留下…
展开
-
Java实现 插入排序!!!
[code="java"]package net.okren.java.sort;import java.util.*;public class InsertSort { public static void insertSort(Comparable[] data){ int j; for(int p = 1; p < data.length; p++){...2009-09-16 20:07:51 · 69 阅读 · 0 评论 -
java 实现 快速排序算法 QuickSort
[code="java"]public class QuickSort { private static Comparable median3(Comparable[] data, int left, int right){ int center = (left + right) / 2; if(data[center].compareTo(data[left...2009-05-12 15:16:27 · 88 阅读 · 0 评论 -
java 实现 归并排序算法 MergeSort,
[code="java"]public class MergeSort { private static void mergeSort(Comparable[] data,Comparable[] tmpArray, int left, int right){ if(left < right){ int center = (left + right) / 2; ...2009-05-12 10:40:57 · 80 阅读 · 0 评论 -
java 实现 堆排序算法
[code="java"]public class HeapSort2 { private static int leftChild(int i){ return 2 * i + 1; } private static void shiftDown(Comparable[] data,int i, int n){ int child; Comparab...2009-05-12 09:32:17 · 54 阅读 · 0 评论 -
HeapSort 堆排序算法Java实现
[code="java"]public class HeapSort { private static int leftChild(int i){ return 2 * i + 1; } private static void percDown(Comparable[] data, int i, int n){ int child; Comparable t...2009-05-11 21:47:14 · 83 阅读 · 0 评论 -
ShellSort 希尔排序算法
[code="java"]public class ShellSort { public static void shellSort(Comparable[] data){ int j; for(int gap = data.length / 2; gap > 0; gap /= 2){ for(int i = gap; i < data.length; i ...2009-05-11 17:15:32 · 71 阅读 · 0 评论 -
java插入排序算法
[code="java"]public class InsertionSort2 { public static void insertSort(Comparable[] data){ int j; for(int p = 1; p < data.length; p++){ Comparable key = data[p]; for(j = p; j > ...2009-04-28 18:17:48 · 95 阅读 · 0 评论 -
//计算两个随机小于等于n的互异正整数互素 的 概率,
[code="java"]//计算两个随机小于等于n的互异正整数互素 的 概率,public class ProbRelPrim { public static double probRelPrim(int n){ int rel =0; int tot = 0; for(int i = 1; i ...2009-04-24 21:15:42 · 343 阅读 · 0 评论 -
//幂运算,
[code="java"]//幂运算,public class POW { public static long pow(long x, int n){ if(n == 0) return 1; if(n == 1) return x; if(isEven(n))//是否 偶数, return pow(x * x, n / 2); ...2009-04-24 20:57:04 · 145 阅读 · 0 评论 -
欧几里得算法,计算最大公因数,
[code="java"]//欧几里得算法,计算最大公因数,public class GCD { public static long gcd(long m, long n){ while(n != 0){ long rem = m % n; m = n; n = rem; } return m; } publi...2009-04-24 20:32:40 · 129 阅读 · 0 评论 -
折半查找,二分查找,
[code="java"]//折半查找,二分查找,public class BinarySearch { public static int binarySearch(int[] a, int x){ int low = 0; int high = a.length - 1; while(low x) high = mid - 1;...2009-04-24 20:12:09 · 53 阅读 · 0 评论 -
求最大子序列和问题的最优算法
[code="java"]//求最大子序列和问题,public class MaxSubSum{ public static int maxSubSum(int[] a){ int maxSum = 0, thisSum = 0; for(int j = 0; j < a.length; j++){ thisSum += a[j];...2009-04-24 16:23:04 · 81 阅读 · 0 评论 -
java 实现 插入排序 希尔排序 冒泡排序 快速排序 堆排序 归并排序 【完美版】...
[code="java"]package net.okren.java;import java.util.*;import java.io.*;public class SortTest{ //插入排序; public static void insertionSort(Comparable[] data){ System.out.println("insert...2009-09-18 16:23:15 · 88 阅读 · 0 评论 -
Java实现 希尔排序
[code="java"]package net.okren.java.sort;import java.util.*;public class ShellSort { public static void shellSort(Comparable[] data){ int j; for(int gap = data.length / 2; gap > 0; gap ...2009-09-16 20:46:53 · 81 阅读 · 0 评论 -
java 实现 快速查找算法 QuickSelect,
[code="java"]public class QuickSelect { private static Comparable median3(Comparable[] data , int left, int right){ int center = (left + right) /2 ; if(data[center].compareTo(data[left]...2009-05-12 16:43:08 · 159 阅读 · 0 评论