
算法
jingsuxuyilq
这个作者很懒,什么都没留下…
展开
-
算法的力量
算法的力量2006年5月 李开复 算法是计算机科学领域最重要的基石之一,但却受到了国内一些程序员的冷落。许多学生看到一些公司在招聘时要求的编程语言五花八门,就产生了一种误解,认为学计算机就是学各种编程语言,或者认为,学习最新的语言、技术、标准就是最好的铺路方法。其实,大家被这些公司误导了。编程语言虽然该学,但是学习计算机算法和理论更重要,因为计算机语言和开发平台日新月异,但万变不离其转载 2012-09-08 20:49:48 · 1183 阅读 · 0 评论 -
复习数据结构之循环队列
code如下#include #include #include #include #define QUEUESIZE 5#define OK 1#define PARAMETER "%d\n"typedef int dataType;typedef int status;typedef struct sQeue{ dataType *base;原创 2013-03-21 19:57:30 · 608 阅读 · 0 评论 -
复习数据结构之队列
直接上code#include #include #include #include #define OK 1#define PARAMETER "%d\n"typedef int dataType;typedef int status;typedef struct QNode{ dataType data; struct QNode * nex原创 2013-03-21 19:55:39 · 545 阅读 · 0 评论 -
复习数据结构之栈
栈是最重要的数据结构之一,所以的函数调用都要用到它,只不过是系统在管理,并且栈在解决实际问题中也很重要。下面贴出常见的对栈的操作。#include #include #include #include #define STACKSIZE 3#define OK 1#define NOK 0typedef int dataType;typedef int status原创 2013-03-21 19:50:04 · 590 阅读 · 0 评论 -
microsoft面试题之10
翻转句子中单词的顺序。但单词内字符的顺序不变。例如输入“I am a student." 输出”student. a am I"。算法:先对整个句子进行翻转,再对每个单词时行一次翻转#include #include #include char* wordLength(char *stringPtr, int *len, int *flag){ assert(str原创 2013-04-03 19:52:44 · 797 阅读 · 1 评论 -
二叉树遍历的实现
下面是二叉树的遍历算法实现,不过对于后序非递归的实现还有点点问题,有空再更新。#include #include #include #include #define OK 1#define FAIL 0#define INPUTPARA "%c"#define STACKSIZE 100/**********define some primary data type******原创 2013-03-10 13:34:47 · 812 阅读 · 0 评论 -
关于树和二叉树的基本概念总结
1.什么是(自由)树?树首先是无向图的一种,并且此无向图要满足下面两个特性:1)连通,即任何两对顶点之间都有路径相连。2)无回路,简单地说就是没有成环。2.什么是森林?当满足树特性2)而不满足1)时称为森林。可以简单地理解为,什么不满足连通性,所以森林中可含有多个(自由)树。3.树的特性假设G = (V, E)是一个无向图,则下面的定义中等价的:1)G是(自由)原创 2013-03-09 19:32:04 · 5665 阅读 · 0 评论 -
搜狗的笔试题
以前找工作的时候去笔试搜狗遇到下面的题目,当时就崩溃了,呵呵,后来我在优快云上发帖了。不过还是不懂。今天在网上看到了一个和这个问题差不多的问题。我决定一定要搞定它。苦思冥想了2小时加高人同事的提示,写出下面算法。题目:一个长度为n的数组a[0],a[1],...,a[n-1]。现在更新数组的各个元素,即a[0]变为a[1]到a[n-1]的积,a[1]变为a[0]和a[2]到a[n-1]的积,..原创 2012-09-13 17:30:01 · 1357 阅读 · 0 评论 -
A Priority Queue
下面是实现优先队列的C代码,其中一定的很多不足,希望大家多多指教!如果大家有什么好的编程规范也可以告诉我,谢谢!/********************************************************************************** * @frief implement a simple priority queue*原创 2012-09-11 20:40:56 · 734 阅读 · 0 评论 -
Quick Sort
#include #define NUM (int)(10)/********************************************************************************** * @brief exchange two numbers *tempPtr1 and *tempPtr2* @param temp原创 2012-09-11 13:51:11 · 504 阅读 · 0 评论 -
heap sort
#include #include void swap( int *temp1, int *temp2 ) //exchange two numbers{ int temp; temp = *temp1; *temp1 = *temp2; *temp2 = temp;}void MaxHeapify(int *arr, int i, int size)原创 2012-09-10 21:32:24 · 407 阅读 · 0 评论 -
the master theorem of divide-and-conquer
PS: The contents below are abstracted from "Introduction to algorithms (third edition)"The proof of the master theorem is omitted because it is so hard to understand. If you are interesting in it, y转载 2012-09-09 11:36:33 · 598 阅读 · 0 评论 -
复习数据结构之二叉查找树
#include #include #include #include typedef int dataType;typedef struct node * BSTptr;struct node{ dataType data; BSTptr lchild; BSTptr rchild;};BSTptr parent1;BSTptr parent2;void add原创 2013-03-21 20:06:29 · 584 阅读 · 0 评论