当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Enterprise Network Planning Based on Huawei eNSP
FreeBSD bnxt以太网驱动源码阅读记录三:
selenium chrome driver运行时的cannot determine loading status from target frame detached问题
This binding to detailed answers
How to create short images and short videos from the media?How to make the click volume reach 10W?
RestTemplate 使用:设置请求头、请求体
Summer training camp-week2 graph theory
最小割和对偶图(未完成)
C语言提高篇(三)
基于华为eNSP的企业网络规划
Introduction to Scala Basic Syntax (3) Various Operators in Scala
图文短视频自媒体怎么创作?如何让点击量达到10W?
鲁大师7月新机性能/流畅榜:性能跑分突破123万!
Do you know Dijkstra of graph theory?
[b01lers2020]Welcome to Earth-1
C# 编译错误:Compiler Error CS1044
RISC-V instruction format and 6 basic integer instructions
GTK:Gdk-CRITICAL **: IA__gdk_draw_pixbuf: assertion ‘GDK_IS_DRAWABLE (drawable)’ failed
【C语言】手把手带你写游戏 —— 猜数字
Oracle数据库的闪回技术









