Binary tree non recursive traversal algorithm

Preorder non recursive (stack implementation) Algorithm idea: Access the root node to the left and down in turn, and then immediately put the node on the stack (until the left child is empty);When you get to the bottom left, the top element of the stack goes out of the stack and turns to the right subtree (judge whether the right child is emp ...

Posted by djot on Wed, 01 Dec 2021 05:04:50 -0800

Explain the Prototype Pattern of Java design pattern in detail

Model introduction Prototype Pattern is used to create duplicate objects while ensuring performance. This type of design pattern is a creation pattern, which provides the best way to create objects. In a software system, it is sometimes necessary to create a certain type of object many times. In order to simplify the creation process, you can ...

Posted by stig1 on Wed, 01 Dec 2021 04:50:46 -0800

leetcode essence of algorithm interview in Dachang 13. Monotone stack

leetcode essence of algorithm interview in Dachang 13. Monotone stackVideo Explanation (efficient learning): Click to learncatalog:1. Introduction2. Time and space complexity3. Dynamic planning4. Greed5. Binary search6. Depth first & breadth first7. Double pointer8. Sliding window9. Bit operation10. Recursion & divide and conquer11 Prun ...

Posted by Chappers on Wed, 01 Dec 2021 02:53:27 -0800

[Day11] three times a day

[Day11] three times a day subject NC58 finds two switching nodes (esay) in the binary search tree describe A binary tree was originally a search binary tree, but two nodes changed their positions, so that the binary tree is no longer a search binary tree. Please output the values of the two wrong nodes in ascending order. (each node has ...

Posted by Whitestripes9805 on Wed, 01 Dec 2021 01:34:12 -0800

Greedy algorithm for single source shortest path (dijestra algorithm)

catalogue 1. Description of single source shortest path problem 2.Dijkstra algorithm idea 3. Specific case analysis 4. Specific code implementation   1. Description of single source shortest path problem ① Given weighted digraph G =(V,E). Where V is the set of all vertices in the graph. E is the set of all edges in the graph, and the ...

Posted by caster001 on Tue, 30 Nov 2021 22:49:01 -0800

Neural network -- Python implements BP neural network algorithm (Theory + example + program)

1, Multilayer perceptron model based on BP algorithm The multilayer perceptron using BP algorithm is the most widely used neural network so far. In the application of multilayer perceptron, the single hidden layer network shown in Figure 3-15 is the most common. In general, it is customary to call a single hidden layer feedforward network a th ...

Posted by Eratimus on Tue, 30 Nov 2021 21:35:36 -0800

LeetCode brush questions - restore IP address #93#Medium

Discussion on the idea and source code of restoring IP address      The problem of restoring IP address is shown in the figure below. This problem belongs to the type of string and backtracking. It mainly focuses on the use of backtracking traversal method and the understanding of the characteristics of string itself. In th ...

Posted by pahunrepublic on Tue, 30 Nov 2021 20:45:04 -0800

Algorithm notes Chapter 7 data structure

1. Stack Simple calculator, C + + code is as follows: #include<cstdio> #include<iostream> #include<string> #include<stack> #include<queue> #include<map> using namespace std; struct node { bool flag; double num; char op; }; stack<node>s; map<char,int>op; string str; queue<node>q; void Cha ...

Posted by brittny85 on Tue, 30 Nov 2021 17:12:24 -0800

Algorithm intermediate learning 1

1, Observation table method Xiaohu went to a nearby store to buy apples. The treacherous vendor used bundling transactions and only provided 6 packages per bag and 8 packages per bag. But now Xiaohu only wants to buy exactly n apples. Xiaohu wants to buy as few bags as possible for easy carrying. If you can't buy exactly n apples, Xiaohu won't ...

Posted by johnrcornell on Tue, 30 Nov 2021 14:46:44 -0800

Recursive divide and conquer --- example 1. Full Permutation

Recursive divide and Conquer - Example 1. Full Permutation 1, Problem description A recursive algorithm is designed to generate the full arrangement of n elements {r1, r2,..., rn} This question is related to Li Kou master station question 46 - the whole arrangement is the same , and Likou master station question 47 - full arrangement II 2, ...

Posted by ale_jrb on Tue, 30 Nov 2021 14:22:12 -0800