数据结构与算法
文章平均质量分 77
BoLann
这个作者很懒,什么都没留下…
展开
-
Java 二分查找
import java.util.*; import java.lang.*; public class BinarySearch { public static int getPos(int[] A, int n, int val) { int mid = 0; int r = n - 1; int l = 0; while (r >= l) { mid = (r原创 2016-04-15 11:43:48 · 636 阅读 · 0 评论 -
实现getMin功能的栈
第一种方式: import java.util.Stack; public class MyStack1 { public static void main(String[] args) { MyStack1Real myStack1Real = new MyStack1Real(); for (int i = 0; i < 10; i++) { myStack1Real原创 2016-07-10 16:41:57 · 536 阅读 · 0 评论 -
用两个栈实现队列
package stackAndQueue; import java.util.Stack; public class TwoStacksQueue { public static void main(String[] args) { TwoStacksQueueReal twoStacksQueueReal = new TwoStacksQueueReal(); for (int原创 2016-07-10 17:35:32 · 406 阅读 · 0 评论 -
Java 快速排序
public class QuickSortJava { public static void main(String[] args) { int[] aa = { 0, 49, 38, 65, 97, 76, 13, 27 }; new QuickSort().quickSort(aa, 0, 7); for (int result : aa) { System.out.原创 2016-06-11 14:09:43 · 392 阅读 · 0 评论 -
Java 希尔排序
public class ShellSortJava { public static void main(String[] args) { int[] aa = { 49, 38, 65, 97, 76, 13, 27 }; int[] result = new ShellSort().shellSort(aa); for (int s : result) { System.原创 2016-06-10 16:55:53 · 306 阅读 · 0 评论 -
Java 直接插入排序
public class InsertionSort { public static void main(String[] args) { int[] aa = { 49, 38, 65, 97, 76, 13, 27 }; int[] result = new InsertionSortJava().insertionSort(aa); for (int s : result) {原创 2016-06-10 15:58:11 · 308 阅读 · 0 评论 -
Java 二叉排序数
package binarySortTree; /* * Java实现二叉排序树 */ public class BinaryNode { private int value; private BinaryNode lChild; private BinaryNode rChild; public BinaryNode(int value, BinaryNode l, Bina转载 2016-05-05 17:46:38 · 546 阅读 · 0 评论 -
再看Java集合
1. 遍历集合 1.1. 使用Iterator接口提供的默认方法forEach(Consumer action),该方法的参数是一个参数式接口 参见: 使用Iterator接口提供的forEachRemaining(Consumer action)类似与上面讲的forEach()方法 (都是consumer) 1.1.1.原创 2016-08-24 20:56:39 · 463 阅读 · 0 评论