2013年10月5日
摘要: import java.util.Collections;import java.util.HashMap;import java.util.Map;import java.util.Queue;import java.util.Stack;import java.util.Vector;import java.util.concurrent.LinkedBlockingQueue;//2叉树常用操作练习public class BinaryTreeTest { //TEST public static void main(String[] args) { BinaryTree tre... 阅读全文
posted @ 2013-10-05 16:38 真心的不懂 阅读(400) 评论(2) 推荐(0) 编辑
摘要: import java.util.Arrays;public class MergeSort { public static void main(String[] args) { MergeSort sort = new MergeSort(); int[] a = {2,4,3,1,0,9,5,6,3,7}; int[] r = sort.sort(a); for(int i = 0 ; i 0 ? a.length - i : b.length - j; boolean sign = a.length - i > 0 ? true : false; if(size > 0... 阅读全文
posted @ 2013-10-05 16:18 真心的不懂 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 题目:3个线程名字分别是A,B,C 现在在console上连续打印10次 ABC 。public class Test { public static void main(String[] args) { Thread a = new Thread(new Task("A",0)); Thread b = new Thread(new Task("B",1)); Thread c = new Thread(new Task("C",2)); a.start(); b.start(); c.start(); } static class 阅读全文
posted @ 2013-10-05 15:39 真心的不懂 阅读(1643) 评论(0) 推荐(0) 编辑
摘要: public class AllSortAlgorithm { public static void main(String[] args) { char[] array = {'a','b','c'}; allsort(array,0,array.length); } private static void swap(char[] array , int i , int j){ if(i != j){ array[i]^=array[j];array[j]^=array[i];array[i]^=array[j]; } } private st 阅读全文
posted @ 2013-10-05 15:37 真心的不懂 阅读(318) 评论(0) 推荐(0) 编辑
摘要: public class BinarySort { public static void main(String[] args) { int[] array = {1,2,4,6,8,12,15,23}; System.out.println(binarysort(array,16)); } private static int binarysort(int[] array,int target){ int low = 0; int high = array.length - 1; while(low <= high){ int middle = ( high +... 阅读全文
posted @ 2013-10-05 15:31 真心的不懂 阅读(209) 评论(0) 推荐(0) 编辑
摘要: public class HeapSort { public static void main(String[] args) { HeapSort sort = new HeapSort(); int[] a = {2,4,3,1,0,9,5,6,3,7}; sort.sort(a); for(int i = 0 ; i = 0 ; i--){ maxHeapify(a,i,a.length); } } private void sort(int[] a){ buildMaxHeap(a); for(int i = a.length - 1 ; i >= 0 ; i... 阅读全文
posted @ 2013-10-05 15:29 真心的不懂 阅读(219) 评论(0) 推荐(0) 编辑