当前位置:网站首页>binary search && tree
binary search && tree
2022-08-02 13:42:00 【Ding Jiaxiong】
22. Binary Search && Tree
Article table of contents
22.1 Binary Search
22.1.1 Recursive code implementation
22.1.2 Time Complexity
- Optimal - O(1)
- Worst - O(logn)
22.2 Tree
22.2.1 Features
- Each node has 0 or more child nodes
- A node without a parent is called a root node
- Each non-root node has one and only one parent
- In addition to the root node, each child node can be divided into multiple subtrees that do not want to intersect
22.2.2 Related Terms
- The degree of a node
The number of child nodes a node contains is called the degree of the node - Degree of the tree
In a tree, the degree of the largest node is called the degree of the tree - Leaf nodes (terminal nodes)
Nodes with degree 0 - Parent Node (Parent Node)
If a node has child nodes, this node is called the parent node of its child nodes - Child node (child node)
The root node of the subtree contained in a node is called the child node of the node - Sibling nodes
Nodes with the same parent are called siblings - The hierarchy of nodes
Starting from the definition of the root node, the root is the first level, and so on - The height or depth of the tree
The maximum level of nodes in the tree - Cousin Nodes
Nodes whose parent nodes are in the same layer are cousins of each other - Ancestors of the node
From the root to all nodes on the branch that this node goes through - Descendants
Any node in the subtree rooted at a node is called the descendant of the node - Forest
A collection of m(m >= 0) disjoint trees is called a forest
22.2.3 Types
- Ordered tree
- Hoffman Tree
- B-tree
- Binary tree
- Complete binary tree
- Full binary tree
- Non-complete binary tree
- Balanced binary tree AVL tree
- sorted binary tree BST tree - including empty tree
- Unordered tree
22.2.4 Binary tree storage
- Sequential storage
- Chain Storage
22.2.5 Application Scenario
Database Index
22.2.6 Binary Tree
Nature
Traverse
- Breadth first
- Find the shortest path
- depth first
- Preorder - root left and right
- Middle order - left root right
- Postorder - left and right roots
- Breadth first
边栏推荐
猜你喜欢
随机推荐
科研试剂DSPE-PEG-VIP,二硬脂酰基磷脂酰乙醇胺-聚乙二醇-血管活性肠肽VIP
C# using 使用方法
【ONE·Data || 排序入门】
【C语言】剖析函数递归(2)
基于flask商城的管理员功能
【C语言】明解数组(1)
二分查找 && 树
面试SQL语句,学会这些就够了!!!
大而全的pom文件示例
鲁大师7月新机性能/流畅榜:性能跑分突破123万!
ttl电平与rs232电平转换电路(232电平定义)
scrapy框架初识1
高效代码静态测试工具Klocwork 2022.2——Portal全新升级、支持RLM
els 长条碰撞变形判断
多个驻外使领馆发提醒 事关赴华出行、人身财产安全
腾讯安全游戏行业研讨会:生态共建,护航游戏产业健康发展
RISC-V instruction format and 6 basic integer instructions
基于华为eNSP的企业网络规划
eclipse连接数据库后插入数据报错null
Ribbon负载均衡的深度分析和使用