![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
学习笔记
Aiden_He
这个作者很懒,什么都没留下…
展开
-
数据结构----双端队列(Deque,顺序存储)C++模板
继承Queue得到enum class Error_code{ success, underflow, overflow};const int maxqueue = 10;template <typename Queue_entry>class Queue{public: Queue(); bool empty() const; Error_code serve(); Error_code append(const Qu原创 2020-06-25 20:21:30 · 324 阅读 · 0 评论 -
冒泡排序 (三版本)
冒泡排序可能是很多人接触到的第一种排序方法,最值会不断的“浮”到区间右端。第一个版本void bubble_sort(int a[], int n){ for (int i = 0; i < n - 1; ++i) // i用于确保区间右端点前移 { for (int j = 0; j < n - 1 - i; ++j) // 需要比较的区间不断前缩 { if (a[j] > a[j +原创 2020-06-04 20:56:42 · 136 阅读 · 0 评论 -
二叉树(Binary_tree)C++ 模板
二叉树节点Binary_node.htemplate<typename Entry>struct Binary_node{public: Binary_node(); Binary_node(const Entry &x);public: Entry data; Binary_node<Entry> *left; Binary_node<Entry> *right;};template<typename Entry>Bin原创 2020-06-03 17:03:25 · 590 阅读 · 0 评论 -
数据结构----队列(Queue,顺序存储)C++模板
C++队列Queue模板,环形队列节省空间const size_t max_size = 100;template<typename Queue_entry>class Queue{public: Queue() :count(0), front(0), rear(max_size - 1) {} bool empty() const { return count == 0; } bool full() const { return count == max_size; }原创 2020-05-20 18:49:51 · 169 阅读 · 0 评论 -
数据结构----栈(Stack,顺序存储)C++模板
C++栈模板(顺序存储)const int max_size = 100;template<typename Stack_entry>class Stack{public: Stack() :count(0) {} void push(const Stack_entry &x); void pop(); const Stack_entry &top() const; size_t size() const { return count; } void cl原创 2020-05-20 18:18:02 · 216 阅读 · 0 评论 -
基数排序(C++, LSD)
基数排序(C++, LSD)对int数据排序, LSD(Least significant digital), 最低位优先。#include <iostream>#include <queue>#include <vector>#include <algorithm>using namespace std;int maxbit(vector<int> &data); //数据最大位数void radixsort(vecto原创 2020-05-20 17:04:24 · 290 阅读 · 0 评论