
数据结构&算法
文章平均质量分 65
二点五次元
hey
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
归并排序 c语言实现
好吧,跟 http://blog.youkuaiyun.com/morewindows/article/details/6678165 差不多是一样的。。#define ARR_SIZE 30#include #include #include void mergeSort(int *arr, int first, int last, int *temp);原创 2012-07-19 18:16:13 · 481 阅读 · 0 评论 -
字符串全排列 C语言实现
参考 http://www.cnblogs.com/python27/archive/2011/12/08/2281352.html#include #include void swap(char *left, char *right){ char tmp = *left; *left = *right; *right = tmp;}void permutatio原创 2012-10-06 16:50:35 · 2261 阅读 · 0 评论 -
按单词翻转字符串 C语言实现
先翻转整个字符串,再翻转每个单词。#include void swap(char *left, char *right){ char tmp = *left; *left = *right; *right = tmp;}void reverse(char *str, int begin, int end){ while(begin < end){ swap(&st原创 2012-10-06 15:25:12 · 1105 阅读 · 0 评论 -
数据结构 算法面试100题 之 二叉树转换成双向链表
本质上是对二叉树进行中序遍历。二叉树节点和链表节点使用同一个struct,只改变指针指向。#include "stdio.h"#include "stddef.h"#include "stdlib.h"#include "assert.h"struct s_node{int value;struct s_node *lNode;struct s_no原创 2012-09-11 16:16:52 · 653 阅读 · 0 评论 -
去除字符串中多余的空格 C语言实现
比如“hello world hey baby”变成“hello world hey baby”思想是设置两个指针,前面的(front)一直往前走直到字符串结尾,后面的(last)复制front当前指向的字符,当遇到多个空格时并不复制,而是等到front指向非空格字符时在往前走。#include #include #incl原创 2012-09-26 22:06:57 · 5908 阅读 · 0 评论 -
数据结构 算法面试100题 之 逐层遍历二叉树元素
其实就相当于图的宽度优先遍历。#include "stdio.h"#include "stddef.h"#include "stdlib.h"#include "assert.h"struct s_treeNode{int value;struct s_treeNode *lc;struct s_treeNode *rc;};typedef原创 2012-09-07 19:35:09 · 482 阅读 · 0 评论 -
快排 c语言实现
#include int split(int a[], int first, int last){int pvt = a[first];int left = first; // can't written as left = first + 1, which will ca原创 2012-08-28 20:38:37 · 873 阅读 · 0 评论 -
二分查找 c语言实现
额,都不知道类别应该选择成神马才合适。#includeint binary(int *arr, int size, int searchValue);int main(){// int arr[] = { 2 5 8 9 12 56 87 99 };e, nothing to say...int arr[] = { 2, 5, 8, 9, 12, 5原创 2012-08-15 16:32:40 · 756 阅读 · 0 评论 -
hash表 c语言实现
简单的hash表实现采用chaining法。#define DIVIDOR 23#define ELE_NUM 100#includetypedef struct t_node{ int value; struct t_node *next;} Node;void build_table(Node **table, i原创 2012-07-19 18:10:12 · 680 阅读 · 0 评论 -
推荐算法学习笔记
在前两天因为一个 } 漏掉而编译器原创 2014-10-26 01:59:22 · 439 阅读 · 0 评论