- 博客(6)
- 收藏
- 关注
原创 Java 面试代码题型
1. 实现斐波那契(Fibonacci)f(N)=F(N-1)+F(N-2),其中f(1)=f(2)=1 public static int method(int n){ if(n<=2){ return 1; }else return method(n-1)+method(n-2); } 2. 查找
2013-06-07 21:40:05 516
原创 网络编程 UDP TCP
//UDP协议 public class UdpDemo { public static void main(String[] args) throws Exception{ DatagramSocket send=new DatagramSocket(); DatagramSocket receive=new DatagramSocket(
2013-05-22 01:37:39 463
原创 设计模式
1. 模版方法设计模式 在定义功能时,功能的一部分是确定的,一部分是不确定的。而确定的部分在使用不确定的部分,那么这时就将不确定的部分暴露出去。由该类的子类去完成。 public abstract class GeTime { public final void getTime(){ long start=System.currentTimeMill
2013-05-20 01:31:13 437
转载 二叉树
下面是是实现二叉树的递归算法的实现,其思想就是,若为空,则其深度为0,否则,其深度等于左子树和右子树的深度的最大值加1: class Node{ String name; Node left; Node right; public Node(String name) { this.name = name; } @Override public
2013-05-19 22:20:30 411
原创 栈,队列 以及 stack, queue 的相互实现 .
//Stack的实现: public class Stack { private int maxSize; private long[] stack; private int top; public Stack(int s){ maxSize=s; stack= new long[maxSize];
2013-05-19 17:02:05 735 1
原创 排序,折半查找
//选择排序 public static void selectSort(int[] arr){ for(int i=0; i i++){ for(int j=i+1; j j++){ if(arr[i]>arr[j]){ int temp=arr[i]; arr[i]=arr[j]
2013-05-19 14:18:54 522
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人