Binary tree series

Single valued binary tree If each node of a binary tree has the same value, the binary tree is a single valued binary tree. true is returned only when the given tree is a single valued binary tree; Otherwise, false is returned. Example 1: Input: [1,1,1,1, null, 1] Output: true Example 2: Input: [2,2,2,5,2] Output: false link /** * Definition ...

Added by dpsd on Sun, 19 Dec 2021 05:16:10 +0200

linux memory management

c language memory interface #include <stdlib.h> void *malloc(size_t size); Array and calloc Use calloc to request data structures with fixed memory size void *r; r = calloc(2,sizeof(struct tmap)); if(!r) { perror("error of calloc"); exit(EXIT_FAILURE); } 2 means to apply for two tmap spaces. The ...

Added by Brand Hill on Sun, 19 Dec 2021 02:52:56 +0200

String matching algorithm

First agree on two concepts, main string and pattern string For example, if you look up the s string in the s string, s is the main string and S is the mode string Search the "cdf" mode string in the main string as follows: Main string and mode string BF Brute force matching is a very simple string matching algorithm, which mat ...

Added by anthill on Sun, 19 Dec 2021 01:05:28 +0200

Super detailed Java implementation of bubble sort, selection sort and insertion sort [super easy to understand] ❀❀❀

Bubble sorting Step analysis and introduction As can be seen from the figure below, when comparing two adjacent elements, the large number will move backward (how to move it later?), so after each comparison, a larger number will be placed at the end, and the last number does not need to be compared, that is, after each comparison, the ...

Added by fibonacci on Sat, 18 Dec 2021 23:03:06 +0200

Java sorting algorithm [updating]

Sorting algorithm refers to sorting one or more groups of data through a specific algorithm, so that the group of data conforms to ascending or descending order, which is convenient for calculation and screening, and improves the efficiency of data processing. Sorting algorithms can be implemented in a variety of computer languages. Here we imp ...

Added by ankhmor on Sat, 18 Dec 2021 21:55:22 +0200

Java multithreading and concurrent programming | synchronization container & Atomic package & CAS algorithm

preface In the multithreaded environment, many classes we use everyday have thread safety problems, such as ArrayList, HashSet and HashMap. How should we deal with the thread problem in the multithreaded environment? What is the CAS algorithm? Is there any other way to achieve thread safety other than synchronized? Optimistic lock? Pessimis ...

Added by Stray_Bullet on Sat, 18 Dec 2021 19:19:51 +0200

Binary sort tree

Binary sort tree Binary sort tree properties: If its left subtree is not empty, the values of all nodes on the left subtree are less than the values of its root nodeIf its left subtree is not empty, the values of all nodes on the left subtree are less than the values of its root nodeIts left and right subtrees are also binary sort trees The ...

Added by M. Abdel-Ghani on Sat, 18 Dec 2021 16:52:32 +0200

Topology sorting, critical path

         Topological sorting What is topological sorting?     in graph theory, topological ordering is a linear sequence of all vertices of a directed acyclic graph (to obtain a topological ordered sequence). And the sequence must meet the following two conditions: Each vertex appears only once.If there is A path from vertex ...

Added by lala on Sat, 18 Dec 2021 15:16:50 +0200

Computer experiment of data structure (Chapter 6) - tree and binary tree I

1. Establish the chain storage structure of binary tree (bracket representation) Algorithm idea: ① If ch = '(': it means that the node p just created has child nodes, and it needs to be stacked as the top node of the stack in order to establish the relationship between it and its child nodes (if a node has just been created, and the subsequ ...

Added by dotwebbie on Sat, 18 Dec 2021 12:28:04 +0200

HashTable source code analysis, thread safe hash table

summary This class implements a hash table for storing key value pairs. Similar to HashMap, it also has two parameters that may affect its performance: initial capacity and load factor. The capacity here is the length of the hash array in the memory storage structure as in HashMap, and its default load factor is usually 0.75. In addition, this ...

Added by Daniel.Conaghan1 on Sat, 18 Dec 2021 05:18:38 +0200