![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
data structure
zhoutonglx
用汗水与泪水去追逐光荣与梦想,亦感受怅然与失落
展开
-
数据结构 树状数组
位运算就是快#include#includeusing namespace std;int a[20];int sum[20];int n;int bit[100];int getsum(int x){ int sum=0; while(x) { sum+=bit[x]; x=x-(x&-x); } ret原创 2015-07-15 19:59:09 · 268 阅读 · 0 评论 -
Sort Algorithm-->Select Sort
Each traversal find the minimal element start from 1 to n,than compare with the index of i,i+1…n-1,if smaller than swap them or next traversal"""select sortlanguate:python3.5author:zhoutonglx"""#orig原创 2016-07-24 23:38:50 · 204 阅读 · 0 评论 -
Sort Algorithm-->Bubble Sort
Bubble sort:Everytime index start from left,compare two elements,if left element bigger then right element,than swap them, or index move to next. After a traverse, the max element of the rest will floa原创 2016-07-24 20:16:45 · 290 阅读 · 0 评论 -
insertion sort
For each time, extract the next unsorted element from 1,2,…n,if current sorted element bigger than unsorted element, move sorted element to the right by 1, or insert the extracted element/* insertio原创 2016-07-25 22:55:21 · 178 阅读 · 0 评论 -
heap
#include<bits/stdc++.h>using namespace std;template<typename T> class Heap{ private: T a[100]; int index; public: void heapipy(); void push(T e); T top(原创 2016-08-29 22:51:34 · 462 阅读 · 0 评论 -
red-black tree
#include<bits/stdc++.h>using namespace std;#define BLACK 1#define RED 0struct node{ int value; int color; node * left; node * right; node * parent;};node * grandparent(node *n)原创 2016-09-21 20:59:53 · 425 阅读 · 0 评论