随笔分类 -  数据结构与算法

上一页 1 2
kmp java implement--转
摘要:http://cs.nyu.edu/~yap/classes/basic/progs/patternMatching/KMP.java/** * @file KMP.java * @synopsis An implementation of KMP matching, derived from * a modification of the Match.java program. * Again, the goal is to find an occurrence of a pattern P in a text T. * CO... 阅读全文
posted @ 2013-12-22 01:19 一天不进步,就是退步 阅读(547) 评论(0) 推荐(0)
java实现插入排序算法 附单元测试源码
摘要:插入排序算法public class InsertSortTest { /** * @param args */ public static void main(String[] args) { int[] a={3,5,9,16,29,47,78,89,94}; int key=47; int[] b=insertSort(a,key); for(int i=0;iunsorted[len-1]){ sorted[sorted.length-1]=key; ... 阅读全文
posted @ 2013-12-14 21:53 一天不进步,就是退步 阅读(829) 评论(0) 推荐(0)
经典面试题(转载)
摘要:地址:http://leonax.net/p/1960/find-circle-in-linked-list/1.单链表找环标准做法是使用两个指针,一个每次往前走2步,一个每次往前走1步,如果两个指针相遇,即说明链表有环,时间复杂度为O(N),空间复杂度为O(1)。2.数组的循环右移比如数组 1 2 3 4循环右移1位 将变成 4 1 2 3, 观察可知1 2 3 的顺序在移位前后没有改变,只是和4的位置交换了一下,所以等同于1 2 3 4 先划分为两部分3.单词逆序先把整个字符串倒序,再把每个单词倒序。4.查字典树形结构,根部是共享的,树枝就分叉了。但是似乎传统的二叉树(Binary Tre 阅读全文
posted @ 2013-04-02 11:51 一天不进步,就是退步 阅读(322) 评论(0) 推荐(0)

上一页 1 2