算法策略
算法策略
乘风踏羽
这个作者很懒,什么都没留下…
展开
-
双向链表
#include "stdafx.h" #include #include #include //定义结点 typedef struct __Node{ int data; struct __Node *pre; struct __Node *next; }Node; //定义带头结点的双向链表 typedef struct __doublyLinkedList{ Node *转载 2014-10-19 20:51:07 · 487 阅读 · 0 评论 -
单链表经典实现
#include "stdafx.h" #include #include #include typedef struct Node { int data; struct Node *next; } Node, *LinkedList; LinkedList createH(int arr[]) { //int arr[5] = {2, 4, 6, 1, 3}; LinkedL原创 2014-10-14 22:15:25 · 512 阅读 · 1 评论 -
练习
1、链表 求两个有序链表的交集 找出倒数第k个元素(或中间元素) 链表排序 http://www.vogella.com/code/index.html http://www.blogjava.net/zzheng/archive/2008/09/05/227305.html 国际化 http://nenyalanye-1.iteye.co原创 2012-08-14 00:01:58 · 541 阅读 · 0 评论 -
链表集锦
/* LNode表示该结构类,是该结构的一个实例 LinkList是该结构类的指针,指代的是一个实例的地址 他们的区别在于访问其成员不一样: LNode.data LinkList->data 举个通俗的例子:人 小明站在河边。 LNode相当于小明 LinkList相当于 在河边的那个人 当 LinkList=&LNode 时候就表示小明在河边 */ typedef struct LNode转载 2012-08-13 07:11:17 · 383 阅读 · 0 评论 -
BM算法
#include #include #include #define MAX_NUM_CHAR 256 int *makeSkip(char *pcPatternStr) { int iCnti; int iPatternLen = strlen(pcPatternStr); int *piSkip = (int*)malloc(MAX_NUM_CHAR *转载 2012-08-11 15:21:15 · 371 阅读 · 0 评论 -
KMP算法
#include #include #include int * geNext(char *pucPatternStr) { int iPatternLen; int *piNext; int iCnti; int iCntj; iCnti = 0; iCntj = -1; iPatternLen = strlen(pucPat原创 2012-08-11 12:08:52 · 329 阅读 · 0 评论 -
全排列集锦
/* 1、递归全排列 2、几种排列组合的算法 3、堆全排列 */ ////////////////////////////////////////////////////////////////////////////// //递归全排列 #include int n = 0; void swap(int *a, int *b) { int m;转载 2012-07-31 23:28:36 · 526 阅读 · 0 评论 -
栈集锦
/* 1、顺序栈 2、双栈 3、链栈 4、顺序栈cpp */ ////////////////////////////////////////////////////////////////////////////////////// //顺序栈 //Stack.h #define INFINITY 65535 #define MAXSIZE 100 typedef int ElemType;转载 2012-07-31 23:27:24 · 374 阅读 · 0 评论 -
哈希表集锦
/* 1、哈希表的地址链表法 */ //////////////////////////////////////////////////////////////////////////////////////// //哈希表的地址链表法 /* 散列表(Hash table,也叫哈希表),是根据关键码值(Key value)而直接进行访问的数据结构。也就是说, 它通过把关键码值映射到表中一转载 2012-07-31 22:54:09 · 361 阅读 · 0 评论 -
字符串集锦
/* 1、使用stringstream分割字符串 2、KMP字符匹配算法 3、Kmp字符串匹配算法改进版 4、KMP算法之二 */ ///////////////////////////////////////////////////////////////////////////// //使用stringstream分割字符串,可以逐个输出 #include #include #incl转载 2012-07-31 22:53:06 · 327 阅读 · 0 评论 -
树集锦
/* 1、二叉树的遍历:前序,中序,后序,层序--包括递归和非递归实现 2、AVL树 3、二叉查找树 */ ////////////////////////////////////////////////////////////////////////////////////////// //二叉树的遍历:前序,中序,后序,层序--包括递归和非递归实现 //tree.h /********转载 2012-07-31 22:52:08 · 376 阅读 · 0 评论 -
各类排序算法
//冒泡排序,稳定排序 void BubbleFun(int arr[], int n) { int i,j; int temp; for(i=1; i<n; i++) for(j=0; j<n-i; j++) { if(arr[i]<arr[j]) { temp = arr[i]; arr[j] = arr[i]; arr[j] =temp; }原创 2011-11-04 12:48:03 · 477 阅读 · 0 评论 -
c++双向链表
#include "stdafx.h" #include //定义链表的结构体。 struct MyList { int nData; MyList* pPre; MyList* pNext; }; //全局的变量,保存链表的头 MyList* g_pHead = NULL; //判断链表是否为空 bool IsEmpty() { //如果头指针指向的是空,链转载 2011-11-04 12:42:55 · 397 阅读 · 0 评论 -
c++模板单循环链表
#include "stdafx.h" #include using namespace std; /*1 应用模板 2使用class定义node,而不是struct */ //链表节点 template class ListNode { public://引用public,避免了使用get,set所带来的麻烦 T data; ListNode*next; public: ListNode(转载 2011-11-04 12:42:03 · 1948 阅读 · 0 评论 -
c++链表添加删除修改
#include "stdafx.h" #include #include "assert.h" #include "windows.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { return 0; } #define COUNT 3 //定义一个节点结构体 struct NODE { unsigne转载 2011-11-04 12:41:02 · 4184 阅读 · 0 评论 -
HashMap用法
//HashMap package com.mo.test; import java.util.Calendar; import java.util.*; public class HashMapTest { public static void main(String[] args) { HashMap hashmap = new HashMap(); for (int i =转载 2011-11-04 13:03:51 · 733 阅读 · 0 评论 -
Hashtable用法
//Hashtable用法 using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { public static void Main()转载 2011-11-04 13:04:27 · 396 阅读 · 0 评论 -
Queue用法
//Queue用法 using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { static void Main(string[] args)转载 2011-11-04 13:05:08 · 439 阅读 · 0 评论 -
SortedList用法
//SortedList using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { public static void Main()转载 2011-11-04 13:05:53 · 651 阅读 · 0 评论 -
stack用法
//stack用法 using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace ConsoleApplication1 { class Program { static void Main(string[] args)转载 2011-11-04 13:06:30 · 1634 阅读 · 0 评论 -
ArrayList 用法
//ArrayList 用法 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace ConsoleApplication { class Program { static v转载 2011-11-04 13:03:07 · 344 阅读 · 0 评论