Creation of Huffman numbers and Huffman coding

Huffman Tree: package Tree; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class HuffmanTree { public static void main(String[] args) { int[] arr = {13, 7, 8, 3, 29, 6, 1}; Node root = createHuffmanTree(arr); preOrder(root); } //Write a preorder traversal method public static void preOrder(Node root) { if (root != null) { root.preOrder(); […]

Java Random can be cracked, the random numbers are no longer random and even more unsafe

Java Random random number generation is unsafe. If the first and second random numbers are leaked at the same time, the subsequent random number sequences can be cracked. The Java Random class uses the Linear Congruential Generator algorithm to generate pseudo-random numbers. The so-called pseudo-random number means that if we use the same seed to […]

The inclusion-exclusion theorem of number theory: the number of numbers in 1-n that cannot be divisible by m numbers (non-coprime)

I have a deep understanding: Discrete mathematics is the core of the algorithm! ! Chapter – “Counting of Set Elements”, knowledge point “Exclusion Theorem” “Inclusion-Exclusion Theorem”; This article will extend the case from the teacher’s class: “The number of numbers from 1 to 1000 that cannot be divided by 5, 6, and 8” to “From […]

random: Generation and application of random numbers in Python

Foreword In actual development, random number generation is often used. The random library is dedicated to the generation of random numbers. It provides a fast pseudo-random number generator based on the Mersenne Twister algorithm. This article will explain in detail the application of random number generation in various scenarios. Generate random numbers For the generation […]

C language | How floating point numbers are stored in memory

Floating point numbers are actually stored in binary form in memory, but they are not stored in the form of original code, complemented code, or complemented code. Common floating point numbers: 3.14159 1E10【Scientific notation 1.0*10^10】 eg: 1.23=12.3*10^-1=0.123*10^1 The floating point number family includes: float, double, long double types Floating point number representation range: defined in […]

random: Generation and application of random numbers in Python

Foreword In actual development, random number generation is often used. The random library is dedicated to the generation of random numbers. It provides a fast pseudo-random number generator based on the Mersenne Twister algorithm. This article will explain in detail the application of random number generation in various scenarios. Generate random numbers For the generation […]

Text editor with tagged line numbers based on QPlainTextEdit

Referenceqt example key code CodeEditor.h file #ifndef CODEEDITOR_H #define CODEEDITOR_H #include <QPlainTextEdit> #include <QPaintEvent> #include <QContextMenuEvent> #include <QMouseEvent> #include <QMouseEvent> #include <QPainter> #include <QTextBlock> #include <QFontMetrics> #include <QTextCursor> #include <QTextBlockFormat> #include <QTextDocument> #include <QTextCodec> #include <QMenu> #include <QScrollBar> QString GetQString(QByteArray byteArray);//Prevent garbled characters enum TagType {<!– –> NUMBER=0, MARKROUND,//circle MARKBLOCK //block }; class TagLineNumberArea; class […]