随笔分类 -  ds

algorithm and data structure.
摘要:1,triplet_head.h 文件 1 #define TRUE 1 2 #define FALSE 0 3 #define OK 1 4 #define ERROR 0 5 #define OVER_FLOW -2 6 7 typedef int Status; 8 typedef int E 阅读全文
posted @ 2017-12-27 18:04 wonkju 阅读(599) 评论(0) 推荐(0)
摘要:概述 还是相对简单,不过要记得释放不用的头结点即可.代码为: 1 //将lList2头结点连接在lList1尾结点的后面. 2 void 3 combine(linklist lList1, linklist lList2) { 4 Linknode *lst01Tail = lList1... 阅读全文
posted @ 2014-12-19 10:53 wonkju 阅读(856) 评论(0) 推荐(0)
摘要:递归实现:真正对递归的调用过程很熟悉的哥们才很顺,虽然这个题目代码看起来不难,但是我在纸上画出调用过程后,才弄明白是什么个过程. 1 //交换所有二叉树的左子树和右子树. 2 void 3 swap(PNode p) { 4 if(!p) return; 5 6 swap... 阅读全文
posted @ 2014-09-18 12:40 wonkju 阅读(622) 评论(0) 推荐(0)
摘要:递归实现: 其实代码看似蛮简单的: 1 //先序遍历. 2 void 3 traverse(PNode p) { 4 if(!p) 5 return; 6 visit(p); //访问根结点. 7 if(p->lchild) 8 tra... 阅读全文
posted @ 2014-09-18 12:37 wonkju 阅读(226) 评论(0) 推荐(0)
摘要:概述:中缀表达式就是我们常常在数学上用的运算符在中间,运算数在旁边的表达式:如 :9+(3-1)*3+10/2转换的过程也不难,仅仅需要一个空栈(用于存储临时操作符)就能解决了. 原理:有两个特例,1是"(",即左括号;2是栈顶运算符的优先级高于当前运算符.具体地说: 顺序扫描中缀表达式... 阅读全文
posted @ 2014-09-16 15:59 wonkju 阅读(726) 评论(0) 推荐(0)
摘要:最近复习考研,加上一直都将"算法"放在很高的位置,所以,蛮重视算法的.不多说了,其实这个问题,不难理解的.主要代码: 1 //反转单链表. 2 void 3 reverse(linklist lList) { 4 Linknode *pre = NULL; //注意该结点不能再指向别的... 阅读全文
posted @ 2014-09-12 00:41 wonkju 阅读(583) 评论(0) 推荐(0)
摘要:这两天开始准备考研了,才回到 算法与数据结构,班里就我一个人选这门了,其他都选 自然地理.要做代码,如果不选 算法与数据结构,就没有意义了.一段时间以来,都把 算法和数据结构看得很重要了.所以这次要全力,定心,好好理解.一,从问题到程序 1,需求模型 2,数学模型 3,实现模型 程序中描... 阅读全文
posted @ 2014-09-05 13:54 wonkju 阅读(210) 评论(0) 推荐(0)
摘要:csdncnblogsinterviewmit 阅读全文
posted @ 2014-04-22 08:27 wonkju 阅读(100) 评论(0) 推荐(0)
摘要:a simple statement to define 'hash function' was: any algorithm that maps data of arbitrary length to data of a fixed length. ref: hash function wikipedia 阅读全文
posted @ 2014-03-29 18:26 wonkju 阅读(221) 评论(0) 推荐(0)
摘要:If you are care a littile about the time your algorithm cost,you should notice that,you my use StringBuilder instead of string itself if you gonna change the string literals. Today,I test them,and the result is so much difference. Nomal string operates: 1 System.Diagnostics.Stopwatch sw = new ... 阅读全文
posted @ 2014-01-10 12:51 wonkju 阅读(597) 评论(0) 推荐(0)
摘要:For all of we programmers,we should always remember that "Premature optimization is the root of all evil". (Ref) When again,I come back to the 'Data Structure and Algorithm',following the algorithms that the .net provides,using the '.net reflector',I realise that I was too 阅读全文
posted @ 2014-01-10 11:59 wonkju 阅读(382) 评论(0) 推荐(0)
摘要:1 //1 加到 100 的 时间复杂度: 2 int n = 100; 3 int sum = 0; 4 for(int i = 1; i n -> ∞. 阅读全文
posted @ 2014-01-08 02:03 wonkju 阅读(951) 评论(0) 推荐(0)
摘要:Array ClassProvides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtimeIn my opinion,int32[] is an example of Array,so is double[] and so on.for instance:1 Int32[] ints = new int[3];2 //... 阅读全文
posted @ 2014-01-07 10:53 wonkju 阅读(444) 评论(0) 推荐(0)