
数据结构代码
shao326
未婚
展开
-
栈的实现
栈的实现:import java.io.*;//栈中的每个节点class Element{ //指向下一个节点 private Element next; //节点中的对象 private Object value; public Element getNext() { return next; } public Object ge...原创 2012-02-27 14:39:12 · 92 阅读 · 0 评论 -
kmp算法 --c语言实现
#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>int next[1000]; //记录跳转位置 int kmp_next(char *base){ int i,j; i=0; j...原创 2012-08-20 10:44:07 · 553 阅读 · 0 评论 -
冒泡排序 --c语言实现
#include <stdio.h>#include <stdlib.h>#include <string.h>//交换两个位置 void swap(int a[],int pos1,int pos2) { a[pos1]=a[pos1]^a[pos2]; a[pos2]=a[pos1]^a[...原创 2012-08-12 12:51:07 · 127 阅读 · 0 评论 -
合并排序 --c语言实现
#include <stdio.h>#include <stdlib.h>#include <string.h>//将两个有序序列合并为一个有序序列 void merge(int a[],int left_pos,int right_pos){ int temp[right_pos-left_pos+1]; int m...原创 2012-08-12 12:22:38 · 354 阅读 · 0 评论 -
快速排序 -- c语言实现
#include <stdio.h>#include <stdlib.h>void qsort(int a[],int left_pos,int right_pos){ if(left_pos<right_pos) { int left=left_pos,right=right_pos; ...原创 2012-08-11 20:36:20 · 135 阅读 · 0 评论 -
堆排序 --c语言实现
#include <stdio.h>#include <stdlib.h>//交换两个位置 void swap(int a[],int pos1,int pos2){ a[pos1]=a[pos1]^a[pos2]; a[pos2]=a[pos1]^a[pos2]; a[pos1]=a[pos1]^a[pos2];...原创 2012-08-11 17:30:11 · 125 阅读 · 0 评论 -
字典树 --c语言
(1)trie.h #ifndef TRIE_H_#define TRIE_H_typedef struct word_trie_t word_trie_t;typedef enum bool bool;enum bool{ false=0, true=1,};struct word_trie_t...原创 2012-03-31 21:20:41 · 353 阅读 · 0 评论 -
二叉查找树 --java代码
代码可能写的不够好,不过是爱心代码,宝贝要看懂哦! (1)tree接口 所有的树,都要实现这样的接口Tree.java 文件public interface Tree { public int get_count(); public void insert(Object obj); public void delete(Object obj); ...原创 2012-02-28 16:20:44 · 101 阅读 · 0 评论 -
二叉查找树 --c代码
二叉查找树实现: #include <stdio.h>#include <stdlib.h>#include <malloc.h>#define malloc_thing(thing) (thing *)malloc(sizeof(thing))//此函数指针用来插入时做比较使用 typedef int (*tree_compa...原创 2012-02-27 14:42:01 · 118 阅读 · 0 评论 -
朴素算法 --c语言实现
#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>int piaoshu(char *s,char *p){ int i,j; //间距不断增大 for(i=0;i<strlen(s)-s...原创 2012-08-20 10:59:24 · 201 阅读 · 0 评论