Skip to content

Commit 882dccb

Browse files
committed
2 parents fa6f452 + 16c9cfa commit 882dccb

3 files changed

Lines changed: 23 additions & 22 deletions

File tree

Algorithm/RBtree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ r2插入在r1左子节点违反规则,对b右旋转
7979
改变r1和b的颜色(在之后的rebalance调整里进行,rotate函数只进行旋转.)
8080
假设A,B为nullptr
8181
b r1 b(r1)
82-
/ \ / \ / \
82+
/ \ / \ / \
8383
r1 A ==> r2 b ==> r2 r3(b)
8484
/ \ / \ / \
85-
r2 B B A B A
85+
r2 B B A B A
8686
*/
8787
void RBtree::right_rotate(treenode* node)
8888
{
@@ -243,4 +243,4 @@ int main(int argc, char const *argv[])
243243
//-2 0 9 10 32 33
244244
rbtree.printbyorder();
245245
return 0;
246-
}
246+
}

Algorithm/RBtree.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class RBtree
1515
private:
1616
/*旋转时根节点可能发生变化,维护一个head节点与根节点相互以parent指向
1717
左子节点指向最左(即最小)节点,右子节点指向最右(即最大)节点.
18-
O <-head
19-
|
20-
O <-root
18+
O <-head
19+
|
20+
O <-root
2121
/ \
2222
A B
2323
*/
@@ -59,4 +59,4 @@ class RBtree
5959
*/
6060
treenode* find_larger(treenode* node);
6161
treenode* find_smaller(treenode* node);
62-
};
62+
};

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
# Data-structure-Algorithm
22
Data structure&amp;Algorithm in C++
33

4-
用简单的写法整理下我理解的数据结构和基础算法.
4+
用简单的写法整理下常见的数据结构和基础算法.
55
在每个完成的cpp文件下都附有相应的简单测试.
6-
大多以STL的实现为标准.
76

87
**已完成**
98

109
| Name | File |
1110
|------|------|
12-
|Binarysearch |https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/binarysearch.cpp |
13-
|Bubblesort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/bubblesort.cpp |
14-
|Insertsort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/insertsort.cpp |
15-
|Mergesort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/mergesort.cpp |
16-
|Quicksort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/quicksort.cpp |
17-
|Selectsort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/selectsort.cpp |
18-
|Shellsort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/shellsort.cpp |
19-
|Heap.h|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/heap.h |
11+
|Binarysearch-二分搜索|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/binarysearch.cpp |
12+
|Bubblesort-冒泡排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/bubblesort.cpp |
13+
|Insertsort-插入排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/insertsort.cpp |
14+
|Mergesort-归并排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/mergesort.cpp |
15+
|Quicksort-快速排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/quicksort.cpp |
16+
|Selectsort-选择排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/selectsort.cpp |
17+
|Shellsort-希尔排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/shellsort.cpp |
18+
|Heap.h-堆|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/heap.h |
2019
|Heap.cpp|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/heap.cpp |
21-
|Heapsort|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/heapsort.cpp |
22-
|Stack.h|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/stack.h|
23-
|Queue.h|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/queue.h|
24-
|BST.h|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/BinarySearchTree.h|
20+
|Heapsort-堆排序|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/heapsort.cpp |
21+
|Stack.h-栈|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/stack.h|
22+
|Queue.h-队列|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/queue.h|
23+
|BST.h-二叉搜索树|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/BinarySearchTree.h|
2524
|BST.cpp|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/BinarySearchTree.cpp|
26-
|AVL.h|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/AVLtree.h|
25+
|AVL.h-AVL树|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/AVLtree.h|
2726
|AVL.cpp|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/AVLtree.cpp|
27+
|RBtree.h-红黑树|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/RBtree.h|
28+
|RBtree.cpp|https://github.com/SheyQ/Data-structure-Algorithm/blob/master/Algorithm/RBtree.cpp|
2829
Continue...

0 commit comments

Comments
 (0)