Algorithm_ Binary tree_ Nearest common ancestor of binary tree
Nearest common ancestor of binary tree
leetcode link
1. Two solutions
Recursion - postorder traversal
Idea: this problem wants to find the nearest common ancestor of two nodes, so we have to traverse the tree from bottom to top, judge the two children first, and then judge the logic of the root node, so we think of using post order trav ...
Added by ryanfern86goa on Wed, 22 Dec 2021 03:03:32 +0200
Group programming ladder GPLT-L2-005 set similarity
Click to go to PTA topic
Input format:
The first line of input gives a positive integer n (≤ 50), which is the number of sets. Then, N lines, each line corresponds to a set. Each set first gives a positive integer m (≤ 10 ^ 4), which is the number of elements in the set; then followed by M integers in the [0,10 ^ 9] interval. The nex ...
Added by rahulephp on Wed, 22 Dec 2021 02:21:39 +0200
Basic skills of data structure and algorithm: whether a single linked list has a ring, two ways
background
Data structure is the basic skill of our programmers, which is often used in daily work and job interview; Moreover, in recent years, the job competition of programmers is becoming greater and greater, and data structures and algorithms have become necessary questions in the interview of large factories. What I know: Huawei technici ...
Added by chenggn on Wed, 22 Dec 2021 02:00:37 +0200
[optimal dispatching] particle swarm optimization algorithm to solve the minimum power purchase problem of optimal dispatching of hydropower plants [matlab phase 1234]
1, Introduction to particle swarm optimization
1 Introduction The group behavior of birds and fish in nature has always been the research interest of scientists. Biologist Craig Reynolds proposed a very influential bird swarm aggregation model in 19 eight 7. In his simulation, each individual follows: avoid collision with neighboring individua ...
Added by mjr on Wed, 22 Dec 2021 01:31:50 +0200
Knapsack problem (various categories)
Mainly write: 0-1 backpack, complete backpack (unlimited number of coins in change), multiple backpack (limited number of coins in change), fractional backpack
0-1 backpack: there are N items and a backpack with a capacity of V. each item can only be used once. The volume of article I is v[i], and the value is w[i]. Solve which items are loade ...
Added by Maracles on Tue, 21 Dec 2021 23:53:54 +0200
[data structure] Trie tree (dictionary tree)
1 Basic Concepts
Trie tree (dictionary tree), also known as word lookup tree, is a data structure that can efficiently store and find string sets (not limited to strings). In y's eyes, it is a very simple data structure. It includes the following three properties:
The root node does not contain characters. Except for the root node, each node ...
Added by robembra on Tue, 21 Dec 2021 13:43:52 +0200
Time complexity VS space complexity, can't you calculate it yet?
The ultimate purpose of studying algorithms is how to spend less time and occupy less memory to complete the same requirements. Cases also demonstrate the differences in time and space consumption between different algorithms, but we can't use time and space. Therefore, Next, we will learn about the description and analysis of algorithm time co ...
Added by czambran on Tue, 21 Dec 2021 09:17:42 +0200
Insert sort - linked list sorting algorithm for array and array storage structure
Insert sort idea
When sorting, each element to be sorted is compared with the previous sorted element. If the reverse order occurs, you need to find a suitable position in the sorted element sequence that can keep it in order, find the insertion position, move the sorted sequence back to make space, and then insert the elements to be sorted;
...
Added by olechka on Tue, 21 Dec 2021 07:46:00 +0200
LeetCode brush notes binary search local order
Local ordering of binary search
We already know that binary search is a search algorithm for finding a specific element in an ordered array.
What if an array is not globally ordered, but locally ordered? At this time, we can use the divide and conquer strategy. We can perform binary search in the locally ordered interval, and then combine eac ...
Added by Rayman3.tk on Tue, 21 Dec 2021 07:36:47 +0200
Learning Java multithreading is enough (good article is worth sharing!)
Multi thread learning
1. Multithreading_ concept
Multithreading, in short, is multitasking. Inter method call: an ordinary method call is a closed path from where to where. Multithreading: opens up multiple paths.
2. Multithreading_ Inherit Thread
There are three ways to create threads:
(1) Inherit Thread(2) Implement Runnable interfac ...
Added by smilesmita on Tue, 21 Dec 2021 05:12:22 +0200