随笔分类 - 数据结构-树&&二叉树
摘要:堆的重要性质就是 儿子的值一定不小于父亲的值 向堆中插入数值时,首先在堆的末尾插入该数值,然后不断向上提升知道没有大小颠倒为止。 从堆中删除最小值时,首先把堆的最后一个节点的数值复制到根节点上,并且删除最后一个节点。然后不断向下交换直到没有大小颠倒为止。在向下交换的过程中,如果有2个儿子,那么选择数
阅读全文
摘要:链表允许我们添加、删除、搜索数据,这种数据结构会在执行时申请必要的内存空间,便于管理动态集合。但是链表的时间复杂度为O(n)。相比之下,使用动态树结构能更加有效地添加、删除和搜索数据。 搜索树是一种可以进行动态插入、搜索、删除等操作的数据结构,可以用作字典或优先级队列。二叉搜索树属于最基本的搜索树。
阅读全文
摘要:Binary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes, or is composed of
阅读全文
摘要:A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted bin
阅读全文
摘要:A graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illus
阅读全文