Data structure and algorithm -- subsequence problem

1. Longest ascending subsequence leetcode300 Dynamic programming: traverse each element. Each element represents the length of the subsequence at the end of the element. You only need to traverse the maximum value of all elements plus one to update the dp array. The state of dp[i] is defined aUTF-8...

Posted by glansing on Tue, 12 Oct 2021 07:13:59 +0530

Establishment of minimum heap and Huffman tree

Zhejiang big data structure The heap is stored in the structural form of a complete binary tree, which is expressed as a structure. The keyword of any node is the maximum value (called the maximum heap) or the minimum value (called the minimum heap) of all subtree nodes, which is expressed as oUTF-8...

Posted by luv2climb on Tue, 12 Oct 2021 08:32:32 +0530

Solving string matching problem with KMP algorithm in Java

14.4 KMP algorithm 14.4.1 application scenario - string matching problem String matching problem: There is a string str1 = "Dili Reba Dili Reba Hello, Dili Reba hello", and a substring str2 = "Dili Reba hello"Now it is necessary to determine whether str1 contains str2. If it exists, it returns UTF-8...

Posted by kickoff3pm on Tue, 12 Oct 2021 11:49:11 +0530

Interviewer: why does Redis implement SortedSet using jump table instead of red black tree?

What is a jump watch The jump table was invented by William Pugh. In his paper Skip lists: a probabilistic alternative to balanced trees, he introduced the data structure, insert and delete operations of the jump table in detail. The paper introduces the jump table as follows: Skip lists are a UTF-8...

Posted by andrin on Tue, 12 Oct 2021 23:33:24 +0530

Data structure personal notes Lesson 10 queue

queue Queue, like stack, is also a linear storage structure with strict requirements for "storage" and "retrieval" of data Different from the stack structure, both ends of the queue are "open", requiring that data can only enter from one end and exit from the other end Generally, one end of inUTF-8...

Posted by BenMo on Wed, 13 Oct 2021 00:11:25 +0530

Java uses Kruskal algorithm to solve the bus stop problem

14.7 Kruskal algorithm 14.7.1 application scenario - bus stop problem Look at an application scenario and question: There are 7 new stations (A, B, C, D, E, F, G) in a city. Now roads need to be built to connect the 7 stationsThe distance of each station is represented by A sideline (weight), fUTF-8...

Posted by EverToDesign on Wed, 13 Oct 2021 06:43:32 +0530

[data structure] National Day Training

POJ 2182 Lost Cows Tree array + bisection. O ( n l o g 2 n ) O(nlog^2n) O(nlog2n). #include using namespace std; #define ll long long inline void read(int &x) { x = 0; int f = 0; char ch = getchar(); while(ch < '0' || ch > '9') { f |= ch == '-'; ch = getchar(); } while(ch >= '0' && ch

Posted by slands10 on Wed, 13 Oct 2021 08:12:21 +0530

Basic to advanced algorithms and data structures

Logarithm By generating random numbers, all random numbers are completely copied. A total of two identical random numbers are generated. Then input the two methods respectively. (the number of input data can be adjusted dynamically) for (int i = 0; i < testTime; i++) { int[] arr1 = generateRanUTF-8...

Posted by wyrd33 on Wed, 13 Oct 2021 08:21:42 +0530

One week to brush and explode LeetCode, teacher Zuo Chengyun - binary tree

Binary tree Recursive and non recursive methods (PreOrder, InOrder, PostOrder) recursion public static void f(Node head) { if (head == null) { return; } //Preorder traversal System.out.print(head.value + " "); f(head.left); //Medium order traversal System.out.print(head.value + " "); f(head.rigUTF-8...

Posted by zytex on Wed, 13 Oct 2021 19:17:04 +0530

Top ten algorithm sorting - quick sorting

introduce Like bubble sort, fast sort is also an exchange sort. The purpose of sorting is achieved by comparing and exchanging positions between elements. Bubble sorting is to move only one element to one end of the sequence in each round, while fast sorting is to find a reference element, movUTF-8...

Posted by chrille112 on Wed, 13 Oct 2021 20:17:42 +0530