数据结构学习
哈哈笑死哈哈
这个作者很懒,什么都没留下…
展开
-
各种排序算法
#include<iostream>using namespace std;void SelectSort(int r[],int n);//选择排序void InsertSort(int r[],int n);//直接插入排序void BinInsertSort(int r[],int n);//折半插入排序void ShellSort(int r[],int n);//希尔排序void Partition(int r[],int i,int j);//快速排序void Sift原创 2022-02-07 21:24:21 · 242 阅读 · 0 评论 -
BF算法模式匹配
#include<iostream>using namespace std;int findstr(char* mainstr, char* sonstr);int main() { char mainstr[100], sonstr[100]; while (1) { cin >> mainstr >> sonstr; int set = findstr(mainstr, sonstr); if (set == -1) cout <原创 2022-01-09 09:57:05 · 246 阅读 · 0 评论 -
链表逆置、合并和相关其他函数
test.h#include<bits/stdc++.h>#ifndef TEST_H #define TEST_Husing namespace std;template <class T> class Node{public: T data; Node<T> *next; Node(T data=0){this->data=data;this->next=NULL;}};template <class T>cl原创 2022-01-09 09:50:53 · 73 阅读 · 0 评论 -
线索二叉树
BiTree.h#include <vector>#include <iostream>using namespace std;enum BiThrNodeType{LINK,THREAD};template <class T>struct BiNode{ BiThrNodeType ltype,rtype; T data; BiNode<T> *lchild; BiNode<T> *rchild;};static BiN原创 2022-01-04 01:09:31 · 223 阅读 · 0 评论 -
CH7(1) 二叉树
// 二叉树2.cpp : Defines the entry point for the console application.//#include<iostream>#include<vector>#include<string>using namespace std;template<class T>struct BiNode{ T data; BiNode <T>* lchild; BiNode <T>原创 2022-01-03 20:57:34 · 669 阅读 · 0 评论 -
哈夫曼树各种函数
HuffmanTree.h#ifndef HUFFMANTREE_H#define HUFFMANTREE_H#include<iostream>#include<vector>using namespace std;struct HuffmanNode{ char data; double weight; int parent,lchild,rchild;};class HuffmanTree{private: vector<HuffmanNod原创 2022-01-02 16:12:28 · 297 阅读 · 0 评论 -
CH9 二分查找和二叉排序树查找
BiSortTree.h#pragma once#include<iostream>using namespace std;struct Binode{ int key; Binode* lchild, * rchild;};class BiSortTree{ Binode* root; void Insert(Binode*& ptr, int k); Binode* Search(Binode* ptr, int k); void Free(Binode原创 2022-01-02 16:06:45 · 127 阅读 · 0 评论 -
CH8 图 (C++类模板)
MyGraph.h#ifndef MYGRAPH_H#define MYGRAPH_H#include <iostream>#include <cstring>#include <queue>#include <vector>#include <iomanip>#include <math.h>using namespace std;template <class T>struct Edge{原创 2022-01-02 16:04:44 · 204 阅读 · 0 评论 -
CH7(2)哈夫曼树 (C++类模板)
Huffman.h#pragma once#ifndef HUFFMAN_H#define HUFFMAN_H#include <iostream>#include <vector>#include <cstring>using namespace std;struct HuffmanNode{ char data; double weight; int parent, lchild, rchild; vector<char>co原创 2022-01-02 16:03:09 · 148 阅读 · 0 评论 -
CH3 中缀表达式(C++类模板)
SeqStack.hpp#include<iostream>using namespace std;template <class T, int Maxsize >class SeqStack{ T data[Maxsize];//存放栈元素的数组 int top;//栈顶指针,指示栈顶元素在数组中的下标public:public: SeqStack();//构造函数 void Push(T x);//入栈 int Stacktop();//返回栈顶元素 T原创 2022-01-02 15:59:40 · 182 阅读 · 0 评论 -
CH2 合并有序顺序表和有序链表(C++类模板)
SeqList.hpp#pragma once#include<iostream>using namespace std;template<class T, int MaxSize>class SeqList{ T data[MaxSize]; int length;public: int MaxSize; SeqList(); SeqList(T a[], int n); int ListLength(); void CreatSeqlist(int原创 2022-01-02 15:57:27 · 127 阅读 · 0 评论 -
二叉树(C++类模板)
BiTree.h#ifndef BITREE_H#define BITREE_H#include<vector>#include<iostream>using namespace std;template <class T>struct BiNode { T data; // 结点数据 BiNode<T> *lchild; // 左孩子的指针 BiNode<T> *rchild; // 右孩子的指针原创 2022-01-02 04:06:58 · 662 阅读 · 0 评论 -
合并有序顺序表和有序链表
SeqList.hpp#pragma once#include<iostream>using namespace std;template<class T, int MaxSize>class SeqList{ T data[MaxSize]; int length;public: int MaxSize; SeqList(); SeqList(T a[], int n); int ListLength(); void CreatSeqlist(int原创 2021-12-28 08:56:46 · 113 阅读 · 0 评论 -
求最大子串
#include<iostream>using namespace std;int MaxSub(char a[],char b[],char c[]);void Sub(int m,int n,char a[],char b[]);void MyCopy(char a[],char b[]);int SubStr(char a[],char b[]);int main(){ char a[100],b[100],c[100]; int i=0; cout<<"请原创 2021-12-27 23:17:30 · 198 阅读 · 0 评论 -
KMP算法
```cpp在这里插入代码片原创 2021-12-27 23:14:46 · 76 阅读 · 0 评论