
数据结构与算法
真理的追求者
这个作者很懒,什么都没留下…
展开
-
单链表
#ifndef LINKLIST_H_INCLUDED#define LINKLIST_H_INCLUDEDtypedef void LinkList;typedef struct _tag_linklistNode LinkListNode;typedef struct _tag_linklistNode{ LinkListNode* next;}; // 结点指针域typedef fl...原创 2018-04-14 16:47:56 · 183 阅读 · 0 评论 -
两个二叉树,判断A与B的关系,是否存在子树 或子结构情况 C++ 实现
#include <iostream>#include <string>#include <vector>using namespace std;struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : v...原创 2018-08-06 17:17:39 · 792 阅读 · 0 评论 -
0/1背包,完全背包,多重背包 问题 C++实现
参考博客 https://blog.youkuaiyun.com/na_beginning/article/details/62884939 /**************************************************** 函数功能:0/1 背包问题 递归和非递归版本* 参数说明* 输入参数: weight = { 3, 2, 4, 7 }; ...原创 2018-08-15 16:52:58 · 548 阅读 · 0 评论 -
最长公共子串问题
最长公共子串问题public static String lcst1(String str1, String str2) { if (str1 == null || str2 == null || str1.equals("") || str2.equals("")) { return ""; } char[] chs1 ...原创 2018-09-12 22:07:37 · 150 阅读 · 0 评论 -
字符串 匹配 KMP算法
/**************************************************** 函数功能:字符串 匹配* 参数说明* 输入参数: string str = "abcabcababaccc"; string match = "ababa";* 输出参数:6* 复杂性分析:时间复杂度:O(N...原创 2018-09-12 22:10:30 · 159 阅读 · 0 评论 -
桶装水问题 C++实现
// 桶装水问题int main(){ for(int k=0;k<20;k++) { int A[7]={0}; for(int ii=0;ii<7;ii++) { int tmep=rand()%6+1; cout<<tmep<<" ";...原创 2018-09-26 18:26:42 · 1164 阅读 · 0 评论 -
一个输入的数组中长度为101,数组范围[1,100],存在一个数重复,找出重复的数
/**********************************************函数功能: 一个输入的数组中长度为101,数组范围[1,100],存在一个数重复,找出重复的数*参数说明* 输入: [1,2,4,5,6,...,39,39,40,41,42,...,100]* 输出: 39*时间复杂度:O(N) 空间复杂度 O(1)*作者:guolia...原创 2018-10-09 21:33:26 · 1516 阅读 · 0 评论 -
常用排序算法的实现 (C++实现)
摘要:本文主要采用C++语言实现冒泡排序、插入排序、选择排序、归并排序、快速排序、堆排序、桶排序。 class My_Sort // 实现从小到大的排序{public: void Bubble_Sort(std::vector<int>& nums); // 冒泡排序 void Insert_Sort(std::vector<int>...原创 2018-12-22 22:06:30 · 218 阅读 · 0 评论 -
利用排序算法解决的一些问题(C++实现)
摘要:排序算法的一些实际应用,如小和问题,逆序对问题,基于非比较排序的相邻两数最大差值问题,以及STL库自定义比较器问题。class Sort_Use{public: int Small_Sum(std::vector<int>& nums); // 小和问题 int Small_Sum1(std::vector<int>& nu...原创 2018-12-23 10:54:31 · 504 阅读 · 0 评论 -
常用排序算法的实现 (Python实现)
摘要:本文主要采用Python语言实现冒泡排序、插入排序、选择排序、归并排序、快速排序、堆排序、桶排序。# -*- coding: utf-8 -*-"""@project : Python_@author : 'Zheng Guoliang'@File : Class1.py@Time : 2018/12/23 13:26"""import...原创 2018-12-23 15:47:19 · 272 阅读 · 0 评论 -
华为 笔试 背包问题 利用动态规划 C++求解
#include <vector>#include <iostream>#include <stdio.h>#include <vector>#include <cmath>using namespace std;int get_MAX(vector<int> weight,vector<int>原创 2018-08-09 08:24:38 · 488 阅读 · 0 评论 -
逆序对问题
#include <iostream>#include <vector>#include <algorithm>using namespace std; class Solution { public: void smallSum(vector<int>& nums) { if(nums.size()<2) r...原创 2018-07-16 10:12:16 · 210 阅读 · 0 评论 -
顺序线性表
#ifndef SEQLIST_H_INCLUDED#define SEQLIST_H_INCLUDEDtypedef void SeqList;typedef void SeqListNode;SeqList* Seqlist_create(int capacity);void Seqlist_destroy(SeqList* list);void Seqlist_clear(SeqList* ...原创 2018-04-14 16:48:09 · 266 阅读 · 0 评论 -
堆排序 C++
#include <iostream>#include <vector>#include <algorithm>#include <string.h> using namespace std; class Solution { public: void heapSort(vector<int>& nu...原创 2018-07-17 11:07:01 · 127 阅读 · 0 评论 -
manacher算法 解决回文字符串问题 c++
#include <iostream>using namespace std;class Solution{public: int manacher(string str) { if(str.size()<1) return 0; string new_str=""; manacher(str,new_str)...原创 2018-07-23 22:19:54 · 465 阅读 · 0 评论 -
Sundy算法 C++实现
class Solution3{public: int getIndexOf(string str,string match) { if(str.size()<1 || match.size()<1 || str.size()<match.size()) return -1; int R=match.size(); ...原创 2018-07-23 22:38:03 · 327 阅读 · 0 评论 -
最长不重复子串 C++
class Solution1{public: /********************************************* *函数功能:最长不重复子串 *参数说明 * 输入: * 输出: *时间复杂度:O( n) 空间复杂度 O( ) *日期: 2018-07-24-00.15 ******...原创 2018-07-24 00:21:32 · 1130 阅读 · 0 评论 -
归并排序 C++实现
#include <iostream>#include <vector>#include <algorithm>using namespace std;class Solution{public: void guibing(vector<int>& nums) { if(nums.size()<2) retur...原创 2018-07-14 08:38:31 · 547 阅读 · 0 评论 -
manacher,Sundy,morris算法 C++实现
class Solution{public: /*************************************************** * 函数功能:寻找最长回文子串 manacher算法 * 参数说明 * 输入参数: * 输出参数: * 复杂性分析:时间复杂度:O(n),空间复杂度:O(n) ...原创 2018-07-26 08:36:32 · 288 阅读 · 0 评论 -
小和问题
#include <iostream>#include <vector>#include <algorithm>using namespace std; class Solution { public: int smallSum(vector<int>& nums) { if(nums.size()<2) re...原创 2018-07-16 09:25:22 · 337 阅读 · 0 评论 -
利用排序算法解决的一些问题(Python实现)
摘要:排序算法的一些实际应用,如小和问题,逆序对问题,基于非比较排序的相邻两数最大差值问题,# -*- coding: utf-8 -*-"""@project : Python_@author : 'Zheng Guoliang'@File : Class2.py@Function : @Time : 2018/12/23 15:51...原创 2018-12-23 17:20:08 · 371 阅读 · 0 评论