Red black tree principle and java implementation
Red black tree
Red black tree rule features:
Nodes are red or black;The root node must be black;All leaf nodes are black and null;The two child nodes connecting the red node are black (no adjacent red nodes appear in the red black tree);Starting from any node, the path to each leaf node contains the same number of black nodes;The nodes newl ...
Posted by martincrumlish on Wed, 12 Jan 2022 12:45:50 +0100
Detailed explanation of search and optimization
Depth first search (DFS)
The idea of depth first search is to start from a node and keep accessing its child nodes deep until its child nodes have no other nodes connected with it except its father. Then go back to its father node and continue the previous operation.
Therefore, depth first search is a recursive process.
After understanding the ...
Posted by sofasurfer on Wed, 12 Jan 2022 12:43:16 +0100
Reproducing German enigma machine in World War II with Python
Enigma comes from Greek and is interpreted in English as "a mystery, an incomprehensible thing".
-- Excerpt from Ele Laboratory
As we know, enigma machine is an important information encryption machine of the German army in World War II, which has many characteristics.
First of all, it is an all-in-one encryption and decryption ...
Posted by Sephirangel on Wed, 12 Jan 2022 11:59:43 +0100
(number theory) from judging prime numbers to prime sieve
Prime numbers, also known as prime numbers, refer to natural numbers that have no other factors except 1 and itself among natural numbers greater than 1.
Simply put, it can only be written in the form of 1 x itself
Note: specified 1 is not prime
The study of prime numbers has always been the focus and difficulty of human research since ancie ...
Posted by Chotor on Wed, 12 Jan 2022 11:07:16 +0100
Problem solving [CTSC2002] Toy Soldier
Let's discuss the problem separately from the three units
Cavalry and infantry: because one super ability can be changed at any time, it is easy to think of going to the third stage for an infantry
i
i
For i points, the number of times they use super ability shoul ...
Posted by locomotive on Wed, 12 Jan 2022 09:37:18 +0100
Data structure -- 6 sort
In our study of data structure, sorting is undoubtedly a very important algorithm. It should be described as an algorithm rather than a data structure. There will be many sorting algorithms in sorting. These sorting algorithms have their own advantages and disadvantages. They are designed with the wisdom of predecessors. There are many excellen ...
Posted by dominod on Wed, 12 Jan 2022 08:21:00 +0100
Data structure and algorithm 12 quick sorting (fast sorting)
3.7 quick sort (quick sort)
Quick sort is an improvement of bubble sort. Its basic idea is to divide the data to be sorted into two independent parts through one-time sorting. All the data in one part is smaller than all the data in the other part, and then quickly sort the two parts of data according to this method. The whole sorting proce ...
Posted by sara_kovai on Wed, 12 Jan 2022 07:28:18 +0100
Graph theory Floyd algorithm and its extended application
1, AcWing 1125 Cattle travel
[Title Description] Farmer John's farm has many pastoral areas, and some paths connect some specific pastoral areas. A pastoral area with all the connections is called a pasture. But for now, you can see that at least two pastoral areas are not connected. Now, John wants to add a path to the farm (note that there i ...
Posted by cjl on Wed, 12 Jan 2022 04:06:32 +0100
Data structure --- string
data structure C++
strand
Several concepts
substring and main string: the substring s2 composed of any consecutive characters in the string s1 is called the substring of s1, and s1 is called the main string of s2 substring position: the position of the first character of the substring in the main string for the first ti ...
Posted by dink87522 on Wed, 12 Jan 2022 00:05:14 +0100
Redis string
character stringThe standard form of string in C language is NULL(0x \ 0 in hexadecimal) as the terminator. If you want to obtain the length of string, you need to use strlen standard library function. The algorithm complexity of this function is O(n), and you need to traverse the whole string. Redis can't afford such a slow speed,Therefore, th ...
Posted by somethingorothe on Tue, 11 Jan 2022 19:31:46 +0100