![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
搜索
文章平均质量分 76
cjliux
这个作者很懒,什么都没留下…
展开
-
以指派问题为例写的一个用循环实现dfs的方法.(gcc)
以指派问题为例写的一个用循环实现dfs的方法.(gcc)#include #include #include int main(void){ int n, m; while(~scanf("%d%d",&n, &m)) { int Eft[n][m], i, j; for(i = 0; i < n; ++i) { for(j = 0; j < m; ++j) {原创 2015-02-28 19:29:46 · 1302 阅读 · 0 评论 -
算法分析之众数问题O(nlogn)
#include#includeusing namespace std;int mode(vector& a, int left, int right, int& num) { int L = left, R = right; int T = a[L]; while (L < R) { while (a[R] >= T && L < R) --R; a[L] = a[R]原创 2016-10-02 09:04:12 · 3805 阅读 · 0 评论 -
编译原理之标识符拆分
#pragma once#include#include#include using namespace std;const unordered_set keywords({ "auto", "short", "int", "long", "float", "double", "char", "struct", "union", "enum", "typedef", "const原创 2016-10-08 21:06:31 · 2165 阅读 · 0 评论 -
C++实现红黑树建立,销毁,查找,插入和删除
/** RBT.h** Created on: Nov 30, 2015* Author: chris*/#pragma once#includeenum NodeColor{RED, BLACK};typedef int KeyType;struct RBTNode{ RBTNode *right, *left, *p; NodeColor colo原创 2015-12-01 09:10:14 · 765 阅读 · 0 评论 -
C++实现哈希表的创建,销毁,键值插入与删除
/** HashTable.h** Created on: Nov 19, 2015* Author: chris*/#pragma once#include const int numofsizes = 7;const int hashsize[] = { 11, 19, 31, 41, 53, 61, 71 };typedef int KeyType;原创 2015-12-01 09:05:20 · 4369 阅读 · 0 评论 -
C++实现二叉搜索树和AVL树
/* * BST.h * * Created on: Oct 31, 2015 * Author: chris */#ifndef BST_H_#define BST_H_#includetypedef int KeyType;struct ElemType{ int val; ElemType(): val(0) {}};typedef struc原创 2015-11-02 18:55:39 · 350 阅读 · 0 评论 -
C++实现B-树插入删除查找
/* * BMT.h * * Created on: Nov 2, 2015 * Author: chris */#ifndef BMT_H_#define BMT_H_#include#define m 3struct Record{ //empty.};typedef int KeyType;typedef struct BMTNode{原创 2015-11-15 15:19:51 · 1432 阅读 · 3 评论 -
C++实现KMP算法(C风格)
/* * Main.cpp * * Created on: Oct 7, 2015 * Author: chris */#include#includeusing namespace std;bool get_next(const char* pat, int*& next){ int len = strlen(pat); next = new int[原创 2015-10-07 17:05:52 · 370 阅读 · 0 评论 -
C++实现KMP模式匹配算法
#include#include#includeusing namespace std; void Next(const string & pat,vector & next){ next.resize(pat.length()); if(pat.length() == 0) return; next[0] = -1; for(size_t pos = 1; pos原创 2015-08-20 23:22:52 · 1004 阅读 · 0 评论 -
C++ 最大流(push-relable)算法
// The push-relable algorithm code due to CLRS chapter 26#include#includeusing namespace std;const int N = 100;int n; // vertex numberint e[N]; // residual flow of the vertexint h[N]; // height转载 2015-06-20 11:26:54 · 929 阅读 · 0 评论 -
C++ 基于Dijkstra算法和基于BFS算法的Ford Fulkson算法比较
#include#include#include#include#include#include#include#include#includeusing namespace std;const int INF = INT_MAX;//Edmond Karp.bool EK_bfs(vector > &G, int src, int dest, vector &Pr原创 2015-06-20 09:25:47 · 981 阅读 · 0 评论 -
C++ 基于Dijkstra最短路搜索的Ford Fulkson最大流算法
#include#include#include#include#includeusing namespace std;const int MAXN = 120;const int INF = INT_MAX;int G[MAXN][MAXN], N;int dist[MAXN], Pre[MAXN];bool visited[MAXN];int times = 0原创 2015-06-20 08:32:04 · 1086 阅读 · 0 评论 -
背包问题思想的一个应用
背包问题的一个应用: 题目背景:从N个数中找出若干个数使它们的和为M,输出满足条件的数组,并统计数组的数目这是一个查找的问题. 用dfs的话,本人代码如下:#include<stdio.h>#include<string.h>#include<sys/time.h>#define NEXT {\ ++i; \ p[i] = 0;\ continue;}#defi原创 2015-02-28 23:35:09 · 1145 阅读 · 0 评论 -
算法分析之有重复元素的排列问题O(n!)
#include#include#includeusing namespace std;templatevoid quicksort(vector& a, int left, int right, vector& next){ int L = left, R = right; eT T = a[L]; while (L < R) { while (a[R] >= T &&原创 2016-10-02 10:03:37 · 2495 阅读 · 0 评论