[stetch cup · blue bridge on cloud - algorithm training camp] week 3 python
Question 1: 509. Fibonacci number
Fibonacci numbers are usually represented by F(n), and the sequence formed is called Fibonacci sequence. The sequence starts with 0 and 1, and each subsequent number is the sum of the first two numbers. That is:
F(0) = 0,F(1) = 1 F(n) = F(n - 1) + F(n - 2), where n > 1 Here you are n, please calculate F(n ...
Added by sousousou on Tue, 25 Jan 2022 17:07:57 +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
Leetcode brush questions must be reviewed II (Leetcode 912 215 315 53)
912. Sort array
Merge
def sortArray(self, nums: List[int]) -> List[int]:
def merge_sort(nums, l, r):
# Termination conditions
if l >= r: return
# Recursive partition array
m = (l + r) // 2
merge_sort(nums, l, m)
merge_sort(nums, m + 1, r)
# ...
Added by chrbar on Tue, 25 Jan 2022 12:51:13 +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
Blue Bridge Cup training match
catalogue
7-1 contraction summation
7-2 isosceles triangle
7-3 settlement issues
7-4 flight time
7-5 global warming
7-6 weights of complete binary tree
7-7 children's worship circle
*7-8 multiple problem
7-9 incrementing triples
*7-10 spiral polyline
*7-11 log statistics
*Maximum product of 7-12
*7-13 fall resistance index
*7-14 t ...
Added by 2kau on Tue, 25 Jan 2022 09:54:55 +0200
GO: basic data type - slice
1, Limitations of arrays
Because the length of the array is fixed and the length of the array is part of the type, the array has many limitations. For example:
func arraySum(x [3]int) int{
sum := 0
for _, v := range x{
sum = sum + v
}
return sum
}
This summation function can only accept [3]int type, and others are ...
Added by pablodelapena on Tue, 25 Jan 2022 09:26:25 +0200
Maximum common divisor and minimum common multiple (c language, detailed)
1, Least common multiple (LCM)
Minimum common multiple = the product of the two input numbers is divided by their maximum common divisor (a*b / maximum common divisor). The key is to find the maximum common divisor;
2, Maximum common divisor (GCD)
1. Rolling division / Euclidean algorithm
Definition: first divide the larger number by the sm ...
Added by VapiD on Tue, 25 Jan 2022 07:49:03 +0200
Data algorithm and structure
Data algorithm and structure
Constant operation
Independent of the amount of data, fixed time operations are constant operations, called big O (letter O), which refers to the awareness of the upper limit, that is, the most time-consuming and worst case
Addition, subtraction, multiplication and division, bit operation and array addressing are co ...
Added by esconsult1 on Tue, 25 Jan 2022 07:14:03 +0200
Random number that generates normal distribution of any mean and variance based on C language. The generated random number can be based on any range or specified range
1. Purpose
Due to the needs of the project, a series of random numbers need to be generated. The random numbers are not uniformly distributed, but based on normal distribution, and the random numbers need to be within the specified interval.
2. Result display
In my project, I want to generate a random number with normal distribution, r ...
Added by fallen_angel21 on Tue, 25 Jan 2022 06:30:26 +0200