java understanding TreeMap ordered collection
TreeMap is a Map collection that can compare the size of elements. It will sort the size of the incoming key s. You can use the natural order of elements, or you can use a custom comparator in the collection to sort.
The tree structure is realized at the bottom of TreeMap, and a structure of red black tree is realized. TreeMap inherits from Ab ...
Added by fantomel on Wed, 26 Jan 2022 03:50:07 +0200
Using Huffman coding to compress the string
Basic introduction
Huffman coding, also known as optimal coding, is a coding method and also belongs to a program algorithm.Huffman coding is one of the classical applications of Huffman tree in telecommunications.Huffman coding is widely used in data file compression, and its compression rate is usually between 20% ~ 90%.Huffman coding is ...
Added by Protato on Tue, 25 Jan 2022 19:51:02 +0200
LeetCode Day5 [data structure] intersection 2 of two arrays, best opportunity for trading stocks
350 Intersection of Two Arrays II intersection of two arrays 2
subject
attempt
First attempt:
class Solution {
public int[] intersect(int[] nums1, int[] nums2) {
Arrays.sort(nums1);
Arrays.sort(nums2);
int[] nums3 = new int[nums1.length + nums2.length];
int size = 0;
for( int i = 0; i < num ...
Added by phice on Tue, 25 Jan 2022 18:41:44 +0200
Why is ConcurrentHashMap thread safe?
ConcurrentHashMap is a multi-threaded version of HashMap. HashMap will have various problems during concurrent operation, such as dead circulation, data coverage and so on. These problems can be perfectly solved by using ConcurrentHashMap. Here's the problem. How does ConcurrentHashMap ensure thread safety? How is its bottom layer realized? Nex ...
Added by bad_gui on Tue, 25 Jan 2022 17:40:56 +0200
Array chapter of force deduction algorithm training and improvement - punch array Statistics - [645] collection of errors
Basic properties of arrays
Array is the simplest data structure.
Array is used to store a series of data of the same type. Data is stored continuously and memory is allocated at one time.
Insert and delete in the middle of the array. All subsequent data must be moved each time to maintain continuity. The time complexity is O(N).
Array index ...
Added by FunkyELF on Tue, 25 Jan 2022 16:29:27 +0200
Binary tree of primary data structure
preface
In the previous data structure blog post, we have learned about the basic binary tree, but today we will explain in detail the traversal of chain binary tree and various operations. The learning of chain binary tree can exercise our recursive thought and divide and conquer thought very well.
Definition of chain binary tree
How ...
Added by TropicalBeach on Tue, 25 Jan 2022 14:26:34 +0200
Algorithm design and analysis binary tree
sketch
Recursive order (recursive access)
Recursion: access order
Recursive order: 1, 2, 4, 4, 2, 5, 5, 5, 2, 1, 3, 6, 6, 3, 7, 7, 7, 3, 1 First order: print the first time in the recursive order, and no operation during the second and third access: 1, 2, 4, 5, 3, 6 and 7 Middle order: print the second time in the recursive order, and ...
Added by Akira on Tue, 25 Jan 2022 10:16:47 +0200
The adjacency matrix representation of undirected graph and the degree of each vertex -- Notes on data structure and algorithm
๐ Reference book: data structure (C language) - edited by Yan Weimin, Tsinghua University Press.
๐ chart
Graph is a more complex data structure than linear table and tree. In the graph structure, the relationship between nodes can be arbitrary, and any two data elements in the graph can be related to each other. The most representative grap ...
Added by woocha on Tue, 25 Jan 2022 06:07:06 +0200
[data structure] hand torn single linked list
I hope to communicate with you and learn from each other through my blog. If you have any mistakes, please correct them in the comment area
1, What is a linked list
Sequential tables have defects in space utilization, system consumption and insertion elements. Linked list is the most commonly used dynamic storage method, which overcomes t ...
Added by saariko on Tue, 25 Jan 2022 06:02:21 +0200
In depth exploration of ArrayList source code parsing
ArrayList set is one of the most commonly used sets in daily development. It is a linear structure. Its bottom layer is implemented by array, which is equivalent to a dynamic array. Let's take a look at how some common methods of ArrayList are implemented.
ArrayList inheritance relationship
Interfaces and classes implemented by inheri ...
Added by kalaszabi on Tue, 25 Jan 2022 05:26:04 +0200