03 2014 档案
摘要:单链表:insertFirst:在表头插入一个新的链接点,时间复杂度为O(1)deleteFirst:删除表头的链接点,时间复杂度为O(1)有了这两个方法,就可以用单链表来实现一个栈了,见http://blog.csdn.net/a19881029/article/details/22579759find:查找包含指定关键字的链接点,由于需要遍历查找,平均需要查找N/2次,即O(N)remove:删除包含指定关键字的链接点,由于需要遍历查找,平均需要查找N/2次,即O(N)public class LinkedList { private class Data{ private Object.
阅读全文
摘要:优先级队列数组实现:public class PriorityQueue { private int[] data; private int size; public PriorityQueue(int size){ data = new int[size]; this.size = 0; } public void push(int toInsert) throws Exception{ if(size == data.length) throw new Exception("Queue is full!"); if(size == 0){ data[0] = toIns
阅读全文
摘要:队列数组实现:队列长度有限,但是考虑到平时一般都使用有界队列,这应该也不算是个缺点public class Queue { private Object[] objs; private int head; private int end; private int size; public Queue(int size){ objs = new Object[size]; this.head = 0; this.end = -1; this.size = 0; } public void push(Object obj) throws Exception{ if(this.size...
阅读全文
摘要:栈数组实现一:优点:入栈和出栈速度快,缺点:长度有限(有时候这也不能算是个缺点)public class Stack { private int top = -1; private Object[] objs; public Stack(int capacity) throws Exception{ if(capacity top: | "); for(int i = 0 ; i top: | 1 | 2 | 2bottom -> top: | 1 | bottom -> top: | 1 | 99 | Exception in thread "main&quo
阅读全文
摘要:长度为N的数组升序排序一,冒泡排序public class BubbleSort { private double[] data; public BubbleSort(double[] data) { this.data = data; } public void sort(){ for(int p = data.length - 1 ; p > 0 ; p--){ for(int i = 0 ; i data[i+1] ){ double tmp = data[i]; data[i] = data[i+1]; data[i+1] = tmp; } ...
阅读全文
摘要:Linux服务器上,将本地编译好的文件上传后,Tomcat启动时报错:Exception in thread "Thread-2" java.lang.ClassFormatError: Illegal UTF8 string in constant pool in class file Server/Request at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) a...
阅读全文
摘要:Distribution为Fedora 19方式一(重启后失效,需root权限):hostname 新主机名[root@promote hadoop]# hostnamepromote.cache-dns.local[root@promote hadoop]# hostname fedora[root@promote hadoop]# hostnamefedora方式二(重启后依然生效,需root权限):网上有很多人说只要修改/etc/sysconfig/network文件,在文件中添加如下2行即可:[root@promote sysconfig]# cat /etc/sysconfig/ne
阅读全文
摘要:public class Test { public static void main(String[] args) { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("StringBuffer"); strBuffer.append(" "); strBuffer.append("Test"); System.out.println(strBuffer.toString()); StringBuilder strBuilder = new StringBu
阅读全文