[data structure] Huffman tree & Huffman coding

Huffman tree definition: Given N weights as N leaf nodes, a binary tree is constructed. If the weighted path length of the tree reaches the minimum, such a binary tree is called the optimal binary tree, also known as Huffman tree. Huffman tree is the tree with the shortest weighted path length, and the node with larger weight is closer to th ...

Posted by glennn3 on Sat, 27 Nov 2021 04:36:33 +0100

Programming language JavaSE (Fundamentals) -- exception mechanism

Programming language JavaSE (Fundamentals) -- exception mechanism Daily saying: the water drop penetrating the stone, its strength comes from accumulation over time preface: Referenced crazy Java basic video—— Crazy Java basic video    catalogue Exception architecture Differences and connections between exceptions 1 ...

Posted by br0ken on Thu, 25 Nov 2021 02:54:29 +0100

Chapter 1 dynamic programming digital triangle model

1. Small summary Common features of this model: Starting from a node, it is only allowed to go in a specific direction to reach the maximum value of the end point.The problem of upgrading needs to go twice (more k times are the problem of cost flow) Set partition method It is divided from all sources of the current state Small questions whe ...

Posted by Haloscope on Mon, 22 Nov 2021 05:34:20 +0100

On fast power of matrix

Before we talk about the fast power of a matrix, let's talk about what a matrix is. About matrix As the name suggests, a matrix is to fill some numbers into a rectangle in the following form: \[\begin{bmatrix}1&4&2&3&5\\9&6&4&1&7\\3&4&5&6&7\end{bmatrix} \]So? So let's talk about matrix multiplicat ...

Posted by MatthewBJones on Thu, 11 Nov 2021 21:07:18 +0100

Force buckle 629 - K reverse order pairs array

Title Description Difficult questions Given two integers n and k, find out the number of different arrays that contain numbers from 1 to N and exactly have k reverse pairs. The definition of reverse order pair is as follows: for the ith and jth elements of the array, if full I < j and a [i] > a [j], it is a reverse order pair; Otherwis ...

Posted by Arab Prince on Thu, 11 Nov 2021 18:27:59 +0100

Day 12_ Dynamic programming [introduction to algorithm]

70. Climb stairs Simple difficulty Suppose you are climbing stairs. You need n steps to reach the roof. You can climb one or two steps at a time. How many different ways can you climb to the roof? Note: given n is a positive integer. Example 1: Input: 2 Output: 2 Explanation: there are two ways to climb to the roof. 1. 1 rank + 1 ra ...

Posted by airwinx on Sun, 07 Nov 2021 05:18:11 +0100

Path planning -- Application of dynamic programming in Apollo Planner and C + + code implementation

What is dynamic programming (DP) Bellman optimal principle    the characteristic of multi-stage decision-making process is that decisions must be made in each stage. The strategy of decision-making process with N stages is a decision sequence composed of n successive stage decisions. Since the termination state of the previous stage ...

Posted by petersro on Thu, 04 Nov 2021 09:50:50 +0100

01 knapsack problem backtracking and dynamic programming solution

Problem description Description A traveler has a backpack that can hold up to m kg. There are n items. Their weights are w1,w2,w3,...,wn respectively, and their values are c1,c2,c3,...,cn respectively. If there is only one item of each kind, seek the maximum total value that the traveler can obtain. Input m. And n (m < = 200, n &lt ...

Posted by tsinka on Thu, 28 Oct 2021 16:47:20 +0200

Data structure and algorithm-1. Longest palindrome substring

1. Longest palindrome substring subject Give you a string s and find the longest palindrome substring in S. Example 1: Enter: s = "bad" Output: "bab" Explanation: "aba" is also the answer to the question. Example 2: Input: s = "cbbd" Output: "bb" Example 3: Input: s = "a" Outpu ...

Posted by fierdor on Sat, 23 Oct 2021 13:43:35 +0200

Codeforces 1312E. Array Shrinking (interval DP stack)

linkkk Meaning: Give a length of n n The sequence of n for the same two adjacent numbers x x x can be replaced by a number x + ...

Posted by Nexy on Tue, 19 Oct 2021 23:28:07 +0200