自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 【Golang 数据结构与法算】 红黑树

GitHub完整代码 完整代码 package tree import ( "data-structures-and-algorithms/contract" "data-structures-and-algorithms/queue" "fmt" "strings" ) // RedBlack 红黑树(4路平衡搜索树) // 红黑树约束(规定了红黑树的渐进平衡性): // (1) 树根始终为黑色 // (2) 外部节点均为黑色 // (3) 其余节点若为红色,则其孩子节点必为黑色 /.

2021-12-23 11:34:58 594

原创 【Golang 数据结构与法算】B-树

GitHub完整代码 代码实现 package tree import ( "data-structures-and-algorithms/contract" "data-structures-and-algorithms/queue" "fmt" "sort" "strings" ) var ( nilItems = make([]interface{}, 16) nilChildren = make([]*btreeNode, 16) ) // b-树节点 // k0 .

2021-12-23 11:32:13 553

原创 【Golang 数据结构与法算】Avl 树

GitHub完整代码 代码实现 // Package tree AVL树,基于二叉查找树的基础上,新增局部节点施加约束:任意节点的左右子树高度差(平衡因子)不大于2. package tree import ( "data-structures-and-algorithms/contract" ) // Avl Avl树 type Avl struct { Bst } // NewAvl 新建空avl树 func NewAvl(cmps ...contract.Comparator) *Avl.

2021-12-21 18:41:40 245

原创 【Golang 数据结构与法算】 Splay 伸展树

GitHub完整代码 代码实现 // Package tree 伸展树:基于局部性原理,将被访问的数据亦步亦趋的伸展至根节点,并在伸展过程中对树进行折叠(降低树高,双层伸展) package tree import ( "data-structures-and-algorithms/contract" ) // Splay 伸展树 type Splay struct { Bst } // NewSplay 新建空伸展树 func NewSplay(cmps ...contract.Compar.

2021-12-21 18:39:48 564

原创 【Golang 数据结构与法算】Bst 二叉搜索树

github 完整代码 查找树接口 package tree import "data-structures-and-algorithms/types" // Interface 查找树约束接口 type Interface interface { Search(v types.Sortable) *BinNode // 二叉树元素查找 Insert(v types.Sortable) *BinNode // 二叉树元素插入 Remove(v types.Sortable) bool .

2021-12-19 22:49:36 439

原创 【Golang 数据结构与法算】BinTree 二叉树

github 完整代码 二叉树节点 // Package bintree 二叉树节点 package bintree import ( "data-structures-and-algorithms/queue" "data-structures-and-algorithms/stack" "data-structures-and-algorithms/types" ) // BinNode 二叉树节点 type BinNode struct { Data types.S.

2021-12-19 11:18:53 600

原创 【Golang 数据结构与法算】sort 冒泡排序算法

github 完整代码 // Package sort 冒泡排序算法 package sort import "data-structures-and-algorithms/types" // BubbleSort 冒泡排序 func BubbleSort(data types.Interface) { BubbleSortRange(data, 0, data.Size()) } // BubbleSortRange 对[lo, hi)区间执行冒泡排序 func BubbleSortRange.

2021-12-18 19:26:20 343

原创 【Golang 数据结构与法算】stack 堆栈

github 完整代码 // Package stack 堆栈 package stack // Stack 栈 type Stack struct { elem []interface{} } // New 初始化空栈 func New() *Stack { return new(Stack) } // Empty 当前栈是否为空 func (s *Stack) Empty() bool { return len(s.elem) <= 0 } // Size 栈元素个数 func .

2021-12-18 19:25:15 339

原创 【Golang 数据结构与法算】 queue 队列

github 完整代码 // Package queue 队列 package queue // Queue 队列 type Queue struct { elem []interface{} } // New 初始化空栈 func New() *Queue { return new(Queue) } // Empty 当前队列是否为空 func (q *Queue) Empty() bool { return len(q.elem) <= 0 } // Size 队列元素个数 fu.

2021-12-18 19:24:22 482

原创 【Golang 数据结构与法算】 forward_list 单向列表

github 完整代码 package forward_list import ( "data-structures-and-algorithms/types" "fmt" "strings" ) // Node 单向列表节点 type Node struct { Data types.Sortable next *Node } // insert 插入v为当前节点后继 func (e *Node) insert(v types.Sortable) *Node { p := &.

2021-12-18 19:23:13 147

原创 【Golang 数据结构语法算】 list 双向列表

github 完整代码 // Package list 双向列表 package list import ( "data-structures-and-algorithms/types" "fmt" "strings" ) // Node 列表节点 type Node struct { Data types.Sortable prev, next *Node list *List } // 新建节点 func newNode(v types.Sortable, .

2021-12-18 19:22:10 274

原创 【Golang 数据结构与法算】 vector 向量

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar

2021-12-18 19:18:34 1067

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除