[data structure] binary tree
Concept and structure
Basic concepts of binary tree
A binary tree is a finite set of nodes, which: 1. Null 2. It is composed of a root node and its left and right subtrees As can be seen from the above figure: 1. The binary tree does not have nodes with a degree greater than 2 2. The subtree of a binary tree can be divided into left and ...
Posted by dsaba on Sat, 25 Dec 2021 20:25:09 +0100
Java daily question -- > sword finger Offer II 030 Insert, delete, and random access are all O's containers
This is [030 on LeetCode. Insert, delete and random access are O(1) containers], and the difficulty is [medium]
subject
Design a data structure that supports the following operations under the average time complexity O(1):
insert(val): returns true when the element val does not exist, and inserts the item into the collection; otherwise, retu ...
Posted by Stressed on Sat, 25 Dec 2021 17:54:50 +0100
Big talk data structure - Search
1. Ordered table lookup
-Binary search
The premise of binary search is that the records in the linear table must be in order of key codes (usually from small to large), and the linear table must be stored in order.
/*Binary search*/
int Binary_Search(int *a, int n, int key)
{
int low, high, mid;
low = 1; /*The lowest subscript of the ...
Posted by visualed on Sat, 25 Dec 2021 15:38:25 +0100
Explanation of stack (the most classic I've ever seen)
1. Preliminary knowledge - program memory allocation
The memory occupied by a program compiled by C/C + + is divided into the following parts:
Stack - it is automatically allocated and released by the compiler to store the parameter values of functions, the values of local variables, etc. its operation mode is similar to the stack in the dat ...
Posted by netpants on Sat, 25 Dec 2021 14:53:34 +0100
PAT class a summary
PAT class a summary - Beginner Level
1, Mathematics
It is often used as a basic 20 point sub topic in PAT. The change of the topic is relatively novel, but the basic idea remains the same.
1.1 prime
Egyptian screening method: to obtain all primes within natural number n, the multiples of all primes not greater than root n must be eliminated ...
Posted by sissy on Sat, 25 Dec 2021 14:42:15 +0100
2021 Niuke multi school 7 f. xay love trees (Chairman tree + DFS sequence)
Question meaning: for a tree with two n points, find the largest subset and meet the following conditions:
The point set is a continuous chain on tree 1The points are set on tree 2 without any ancestral relationship
Idea:
For condition 2:
If point u is the ancestor of point v, then the subtree of u must contain V, that is, it must contain t ...
Posted by Confusion101 on Sat, 25 Dec 2021 14:05:25 +0100
Several common solutions to Hash conflicts when using Hash tables
Hash table
Such as HashMap in Java, a (K,V) data storage structure. The bottom layer of HashMap uses array + linked list, mainly array, not all hash tables.
When adding an element to the hash table, get a hash value from the key of the element through a specific hash function and calculate the storage location stored in the current array.
Ha ...
Posted by Edward on Sat, 25 Dec 2021 08:05:58 +0100
Data structure - Application of stack and queue II
Data structure - Application of stack and queue I
Application of stack in recursion
The essence of recursion is whether the original problem can be transformed into a smaller problem with the same attributes.
Features of function call: the last called function ends first (LIFO).When calling a function, you need to use a stack to store: ① ...
Posted by Whear on Sat, 25 Dec 2021 06:30:03 +0100
Chapter VII - Binary Trees
Basic concepts of binary trees
Binary trees are similar to quadratic trees, but differ slightly from quadratic trees:
A tree with a degree of 2 has at least one node with a degree of 2, which is not required for a binary tree. In short, a binary tree can degenerate into a chain.
2. Trees with 2 degrees can distinguish left from right subtree ...
Posted by SumitGupta on Sat, 25 Dec 2021 00:53:37 +0100
Data structure - linear table
1, Definition and understanding of linear table
Linear table: a finite sequence of zero or more data elements.If the linear table has N elements, the ith element, i-1, is called the direct precursor element of this i element, and i+1 is called the direct successor element of this i element. Each element has and only has one direct precursor an ...
Posted by jakeklem on Fri, 24 Dec 2021 19:15:45 +0100