Shortest path algorithm -- dijkstra
dijkstra
Premise: in a graph, there can be no edges with negative weight.
Give you a starting point. What is the shortest distance from the starting point to all nodes? If a point cannot be reached, the distance to this point is positive infinity (usually in a directed graph).
For example, see the following figure: the set on the right repre ...
Added by kristalys on Mon, 27 Dec 2021 15:05:39 +0200
Data structure STL -- golang implements heap (complete binary tree)
Storage address of GitHub warehouse: https://github.com/hlccd/goSTL
summary
This time, the heap is implemented in the form of Complete Binary Tree.
heap is a general term for a special class of data structures. heap is usually an array object that can be regarded as a tree. heap always satisfies the following properties:
The value of a node ...
Added by NathanS on Mon, 27 Dec 2021 11:03:58 +0200
2021-08-09 design hash set
Design hash set of leetcode daily question
Title Link: https://leetcode-cn.com/problems/design-hashset/
Topic Description: design a hash set without using any built-in hash table library.
Implement the MyHashSet class:
void add(key) inserts the value key into the hash set. bool contains(key) Returns whether the value key exists in the hash ...
Added by Derleek on Mon, 27 Dec 2021 06:29:56 +0200
[Christmas special session] after brushing this set of linked list questions, I laughed when the interviewer took the linked list test
⭐ Introduction ⭐ ️ Hello, I'm Zhijie. I believe you all know the importance of data structure and algorithm. Among them, the linked list is the top priority. Many brothers feel that it is nothing more than a single linked list and a double linked list. It is very simple to add, delete, change and query. Indeed, although the linked list is sim ...
Added by shock on Mon, 27 Dec 2021 05:21:03 +0200
Data structure - tree
Tree 2021 / 8 / 8 20:00
Except for the root node, any node has and has only one precursor
Common properties of trees
Property 1: number of nodes = total degree + 1 (there is an antenna on the head of any node except the root node) Property 2: tree with degree m: the maximum degree of each node in the tree m-ary tree: a tree with at most m ch ...
Added by bike5 on Mon, 27 Dec 2021 04:11:53 +0200
C++ vector and stack introductory exercises (using sorting)
Write a C + + program to read positive real numbers into a vector (in random order) Trailing value - 1. Sorts the numbers in ascending order and displays the sorted numbers. Your program must include the following two functions:
void sort(vector<float> & v);
void display(vector<float> & v);
Solution to Q1:
#include <iost ...
Added by saadatshah on Sun, 26 Dec 2021 22:02:07 +0200
Week 253 of leetcode
This week's competition is relatively simple. I wrote three questions in an hour. The last question, I forgot how to write the longest common subsequence of greedy plus two points. dp's card is lost, and I supplemented it after it.
5838. Check whether the string is an array prefix
class Solution {
public boolean isPrefixString(S ...
Added by warstormer on Sun, 26 Dec 2021 21:12:53 +0200
Detailed analysis of the principle and implementation of Bloom filter (full)
preface
Array, linked list, tree and other data structures will store the contents of elements. Once the amount of data is too large, the consumed memory will also increase linearly Therefore, bloom filter is a data structure to solve the large amount of data
When talking about bloom filter, you need to know some preliminary knowledge poi ...
Added by Lucidnight on Sun, 26 Dec 2021 19:46:50 +0200
[Capriccio 7] the focus of nSum problem is reasonable de duplication
Reference: a method to solve the nSum problem
In an array, given a targer, find n numbers so that their sum is target
For example, the array is [- 4, - 4, - 3, - 2, - 1,0,1,2,3,4,4] When n = 2, target=0, the results are [- 4,4], [- 3,3] When n = 3, target=0, the results are [- 4,1,3], [- 3,1,2] When n = 4, target=1, the result is [- 4, - 2,3, ...
Added by merrydown on Sun, 26 Dec 2021 19:21:02 +0200
[data structure and algorithm] in-depth analysis of the solution idea and algorithm example of the competition round of the best athletes
1, Title Description
N athletes participate in a championship. All athletes stand in a row and number from 1 to n according to the first position (athlete 1 is the first athlete in this row, athlete 2 is the second athlete, and so on).The championship consists of multiple rounds (starting from round 1). In each round, the ith athlete from the ...
Added by ozzthegod on Sun, 26 Dec 2021 15:51:29 +0200