When we search for an integer among n dynamic integers, there are several methods
① Using dynamic arrays, the average time complexity is O(n)
② Using an ordered dynamic array and binary search method, although its worst time complexity is only O(logn), its average time complexity of addition and depth is too high, which is O(n).
③ Using a link ...

Posted by nonexist on Wed, 25 May 2022 04:01:05 +0300

Analysis and java implementation of search related topics in binary tree in Leetcode
In fact, there are some miscellaneous problems in this category. It is basically to find some or a specific value in the binary tree. There are many problems. We will summarize them through two or three articles, but generally speaking, it is basically BFS, whi ...

Posted by HavokDelta6 on Mon, 23 May 2022 10:13:08 +0300

Improvement of binary tree traversal algorithm
The depth first traversal algorithms of binary tree are implemented by recursive functions, which is very inefficient. The reason is that the system calls a stack and does complex operations such as protecting the site and restoring the site, so that the traversal can be realized by very simple cod ...

Posted by Verrou on Sun, 22 May 2022 02:06:38 +0300

Serialize and deserialize binary search trees
Title [leetcode449]
Serialization is the process of converting a data structure or object into a series of bits so that it can be stored in a file or memory buffer, or transmitted over a network connection link for later reconstruction in the same or another computer environment.
Design an algorithm ...

Posted by idire on Wed, 18 May 2022 13:53:33 +0300

Overview
Ordinary binary tree, with left and right child nodes, as shown below
For a leaf node, its left and right child nodes are empty, and some non-leaf nodes may have only one child node, and each node will occupy a space, which will waste the created space.
Threaded binary tree, exploiting these spaces
Threaded Binary Tree
Threaded B ...

Posted by zackcez on Sun, 15 May 2022 12:04:10 +0300

Clue binary tree
This paper refers to the data structure of Dahua
principle
For a binary list with n nodes, each node has a pointer field pointing to the left and right children, so there are 2n pointer fields in total. The binary tree with n nodes has a total of n-1 branches, that is, there are 2n-(n-1)=n+1 empty finger needle fields. ...

Posted by Satria Ox41464b on Sun, 08 May 2022 08:35:18 +0300

Binary tree
Definition of binary tree
A binary tree is a finite set of nodes (recursively defined) ① This set is either empty; ② Or it is composed of a root node and two disjoint binary trees called left subtree and right subtree.
Five basic forms of binary tree
Difference between binary tree and quadratic tree
① Different degrees
A tre ...

Binary tree implementation
//Node class of tree
public class TreeNode<T> {
//Store data
public T data;
//Point to left child and right child nodes
public TreeNode<T> left,right;
public TreeNode(T data, TreeNode<T> left, TreeNode<T> right) {
super();
this.data = data;
this.le ...

Posted by Ambush Commander on Fri, 06 May 2022 08:18:21 +0300

introduction
Original link: A text will take you to understand binary tree I hope you can pay attention to my official account. There is a QR code at the end of the text. Thank you!
1. Basic concepts of binary tree
Binary tree definition: the degree of a node is at most 2
Five forms of binary tree:
Empty binary tree
There is only ...

Posted by fahrvergnuugen on Sat, 30 Apr 2022 01:27:55 +0300

Data structure: the structure in which data is stored
Algorithm: how to operate data? It is more efficient and saves resources
data structure
It can be divided into linear structure, tree structure and graph
Animation effect
Linear table
Data is arranged like a line, mainly including array, linked list, queue, stack, etc
...

Posted by php-phan on Thu, 28 Apr 2022 20:28:54 +0300