C language - four operations of stack (with decimal point and parentheses)
Idea:
The whole process is to traverse the string of the required operation input once Each time an element is judged and operated, there are two stacks (a number stack and a symbol stack) (1) If it is a number, put it on the number stack, and then continue to operate on the element in the next string Here are some operations on parentheses: I ...
Posted by tommix on Sat, 02 Oct 2021 05:04:49 +0200
java implementation of simple binary tree
Basic knowledge of binary tree:
1, Definition of tree
Tree is a kind of data structure. It is a set with hierarchical relationship composed of n (n > = 1) finite nodes.
The tree has the following characteristics:
(1) Each node has zero or more child nodes
(2) A node without a parent node is called a root node
(3) Each non root node h ...
Posted by titangf on Fri, 01 Oct 2021 22:28:44 +0200
Array Element Loop Left Shift n Locations (JAVA)
Description of the problem:
Store n(n>1) integers in a one-dimensional array R, and design an algorithm that is as efficient as possible in both time and space. Move the sequence loop stored in R to the left of p(0<p<n) positions, i.e., transform the data in R (x0,x1,x2,... x(n-1)) to (x p, x(p+1),..., x(n-1),x0,x1,..., x(p-1))
Exa ...
Posted by travelbuff on Fri, 01 Oct 2021 18:25:19 +0200
Lock implementation and concurrent data structure
Lock: it is placed around the critical area to ensure that the critical area is executed like a single atomic instruction. The lock makes the chaotic state originally scheduled by the OS controllable.
Implementation of lock
Discuss the goal that should be set before implementation, so how to evaluate the effect of a lock implementation? T ...
Posted by jmoreno on Fri, 01 Oct 2021 02:13:47 +0200
[postgraduate entrance examination] sequence list and linked list
Sequential table structure
Static allocation of sequential storage
#define MaxSize 50 / / define the maximum length of a linear table
typedef int Elemtype//Assume that the element type in the table is int
typedef struct{
ElemType data[MaxSize];//Elements of sequential table (array)
int length ;//Current length of sequence table
}
Dyna ...
Posted by no_one on Thu, 30 Sep 2021 21:55:44 +0200
step05 day15 learning notes
1. Traditional hash, consistency hash and hash slot
1.1 traditional hash (hard hash)
In the distributed system, it is assumed that there are n nodes, which is used in the traditional scheme mod(key, n) Map data and nodes. When the capacity is expanded or reduced (even if only one node is increased or decreased), the mapping rela ...
Posted by FarhanKhalaf on Tue, 28 Sep 2021 23:14:21 +0200
Chain Table of Leetcode Brush Titles
Chain Table Paper
24.Nodes in a two-way exchange chain table
Idea 1: Introduce sentinel node, adopt double pointer pre, cur
class Solution(object):
def swapPairs(self, head):
auxi = ListNode(0,next = head)
pre,cur = auxi,head
while cur and cur.next:
tmp = cur.next
cur.next = tmp.next
...
Posted by Gath on Sun, 26 Sep 2021 19:13:25 +0200
An algorithm derived from Full Permutation -- backtracking DFS
The idea of backtracking is simple: go forward from one way, go in if you can, go back if you can't, and try another way. Of course, this is too abstract. The idea used in the algorithm is to transform it into trees and graphs. The simple description of the idea of backtracking method is that the solution space of the problem is transformed int ...
Posted by who_cares on Sun, 26 Sep 2021 08:02:34 +0200
Learning notes of data structure, algorithm and application - C + + language description - competition tree
1, Winner tree
Suppose n players take part in a tennis match. The rule of the game is "sudden death": as long as a player loses a game, he will be eliminated. A pair of players play one-on-one, and finally only one player remains unbeaten. We use binary tree to describe the game process. Each external node represents a player, ea ...
Posted by excence on Sat, 25 Sep 2021 12:59:48 +0200
Data structure and algorithm linked storage structure (single linked list)
Chain storage structure: the location of nodes in the memory is arbitrary, that is, logically adjacent data elements are not necessarily adjacent physically. It is also called non sequential image or chain image
Implementation: a group of storage units with arbitrary physical location are used to store the data elements of the linear table. Th ...
Posted by mr_mind on Sat, 25 Sep 2021 12:42:01 +0200