![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 51
痕枫冷
geek,喜欢研究技术
展开
-
快速排序Java代码
package algorithms; import java.util.Random; public class QuickSort { private static Random rand = new Random(); /** * 快速排序法 */ public static void main(String[] args) { int[] b原创 2012-06-20 19:47:00 · 1455 阅读 · 0 评论 -
C语言数据结构学习之数组线性表
#ifndef _SEQLIST_H #define _SEQLIST_H #define LIST_INIT_SIZE 2 #define LIST_INCREMENT 1 typedef int ElemType; typedef struct{ ElemType *elem; int length; int listsize; }SeqList; void addSeq原创 2013-06-15 13:04:08 · 1175 阅读 · 0 评论 -
常规递归和尾递归的性能比较
package net.liuyx.algorithm; public class Fibonacci { private static int[][] a = { { 1, 1 }, { 1, 0 } }; /** * @param args */ public static void main(String[] args) { f原创 2012-08-31 18:05:43 · 869 阅读 · 0 评论 -
不断提高binarySearch的性能
import java.util.Random; public class Test { static Random rand = new Random(47); static int[] a = new int[1000]; static int len = a.length; /** * @param args */ public static void main(Str原创 2012-08-08 10:11:32 · 780 阅读 · 0 评论 -
AVL平衡树
package net.liuyx.algorithm; import java.util.Comparator; public class AVL { private static class AvlNode { @SuppressWarnings("unused") public AvlNode(E theElement) {转载 2012-07-13 11:34:30 · 644 阅读 · 0 评论 -
二叉查找树
package net.liuyx.algorithm; import java.util.Comparator; public class BinarySearchTree { private static class BinaryNode{ public BinaryNode(E theElement) { this(theElem转载 2012-07-12 15:32:37 · 503 阅读 · 0 评论 -
利用快速排序的子程序查找中位数
package net.liuyx.algorithm; import java.util.Random; public class QuickSelect { public static void main(String[] args) { int[] a = generateRandomArray(); QuickSort.quickSort(a,原创 2012-06-27 12:02:44 · 1458 阅读 · 0 评论 -
用数组实现Stack
package algorithms; import java.util.EmptyStackException; public class Stack { private T[] elements; private int top; @SuppressWarnings("unchecked") public Stack(int initCapacity){ el原创 2012-06-27 23:08:23 · 953 阅读 · 0 评论 -
二分法求Fibonacci数列
package net.liuyx.algorithm; public class Fibonacci { private static int[][] a = { { 1, 1 }, { 1, 0 } }; /** * @param args */ public static void main(String[] args) { i原创 2012-06-25 09:17:49 · 612 阅读 · 0 评论 -
计数排序(CountingSort)
计数排序不是基于比较的,而是先了解输入数组元素的特征,放在一个辅助数组中,该数组计算出小于等于数组中某个数的个数,排序如下: package algorithms; public class CountingSort { /** * @param args */ public static void main(String[] args) { int[] a原创 2012-06-23 13:00:40 · 679 阅读 · 0 评论 -
基数排序(radixSort)
package algorithms; public class RadixSort { static int[] a = { 329, 457, 657, 839, 436, 720, 355 }; public static void main(String[] args) { radixSort(); for(int i : a){ System.o原创 2012-06-24 21:58:29 · 587 阅读 · 0 评论 -
堆排序Java代码
package algorithms; import java.util.Random; public class MaxHeapify { private static int heapSize; public static void main(String[] args) { Random rand = new Random(); int[] a = n原创 2012-06-20 19:42:42 · 2736 阅读 · 0 评论 -
高性能二分查找BinarySearch循环取代递归版
二分查找代码: package net.liuyx.algorithm; public class BinarySearch { /** * @param args */ public static void main(String[] args) { int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };原创 2012-06-20 14:00:46 · 1090 阅读 · 0 评论 -
double2int快速解法
#include #define MAGIC 6755399441055744.0 #define MAGIC_DELTA 0.49999999999999 static inline int double2int(double d) { unsigned int s = (*(long long*)&d) >> 63; // 0 or -1 0: -delta -1:原创 2016-04-23 21:42:42 · 1510 阅读 · 0 评论