[Leetcode] self designed data structure of data structure -- python version
This article summarizes the common algorithms of designing data structure according to labuladong's algorithm sketch, which is implemented in Python 3
LRU algorithm
LRU(Least Recently Used) algorithm is a cache elimination mechanism. The computer's cache capacity is limited. If the cache is full, some contents will be deleted. What content ...
Posted by sintax63 on Wed, 05 Jan 2022 11:29:59 +0100
C language implementation of basic search algorithm
1. Sequential search
Sequential search is the basic search algorithm for traversing and comparing the array / linked list according to the original sequence.
1.1 algorithm implementation
Start with the last data element in the table and compare with the key of the record one by oneIf the matching is successful, the search is successful; Conv ...
Posted by Aldark on Wed, 05 Jan 2022 10:47:34 +0100
Section 2 Java8 Stream programming (Lambda expression) 2021-12-29
General directory of Java components
1 Stream overview
It belongs to a kind of structured programming. The main idea is to realize a series of operations on data through chain function calls.
In JDK8, Stream is an interface, which contains many methods that can operate on the data in the Stream. These methods fall into three categories:
...
Posted by damien@damosworld.com on Wed, 05 Jan 2022 09:44:58 +0100
Elegant violence - Introduction to sequence blocking
summary
Interval problems are generally very flexible and can be solved by segment tree, although the time complexity can be achieved
O
(
l
o
g
(
...
Posted by loquela on Wed, 05 Jan 2022 05:48:59 +0100
Summary of data structure related strings in postgraduate entrance examination
Summary of data structure related strings in postgraduate entrance examination
1, Basic concept of string
String: it is a finite sequence composed of zero or more characters, marked as: S = 'a1 a2... an' (n ≥ 0) ai ∈ V character set, each ai (1 ≤ i ≤ n) can be letters, numbers or other characters. String is also a specific ...
Posted by jdh on Wed, 05 Jan 2022 04:25:32 +0100
2022-1-2 data structure tree down (c language code)
1. Binary search tree
definition Binary search tree (BST) is also called binary sort tree or binary lookup tree Binary search tree: a binary tree, which can be empty; If it is not empty, the following properties are met:
All key values of non empty left subtree are less than those of its root nodeAll key values of non empty right subtree are ...
Posted by tom_b on Wed, 05 Jan 2022 03:58:22 +0100
Algorithm -- dynamic programming
dynamic programming
definition
dynamic programming (DP): finding the optimal solution under multiple branches
working principle
To solve a complex problem, first solve its sub problems (first solve the sub problems, and then gradually solve the big problems)
This is a typical recursive idea, eg: fiborache sequence
Application scenario
T ...
Posted by jbruns on Wed, 05 Jan 2022 01:45:34 +0100
[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of "stone game IX"
1, Title Description
Alice and Bob designed a new stone game again. There are n stones in a row. Each stone has an associated number to represent its value. They give you an integer array stones, where stones[i] is the value of the ith stone.Alice and Bob take turns in their own rounds. Alice takes the lead. In each round, players need to remo ...
Posted by NME on Tue, 04 Jan 2022 23:15:23 +0100
Prim algorithm, minimum spanning tree of graph, c/c + + description
The spanning tree of graph is the minimum connected subgraph of graph, which contains all vertices in the graph, but only the number of edges 1 less than the number of vertices. No matter how small the number of edges is, it will not be connected. If there is one more edge, there will be multiple paths between vertices. The tree with the ...
Posted by xhitandrun on Tue, 04 Jan 2022 23:13:09 +0100
Data structure and algorithm [Python implementation] search and basic sorting
1, Hanoi Tower problem
def hanoi(n,a,b,c): #Move from a through b to c
if n>0:
hanoi(n-1,a,c,b) #Move from a through b to c
print("disc%d moving from %s to %s" %(n,a,c))
hanoi(n-1,b,a,c) #Move from b through a to c
hanoi(2,'A','B','C')
The recurrence formula h(x)=2h(x-1)+1 is about equal to the nth power of 2 ...
Posted by kidsleep on Tue, 04 Jan 2022 18:53:04 +0100