Binary tree pre, middle and post order traversal, iteration and Morris writing records

Binary tree pre, middle and post order traversal, iteration and Morris records Preorder traversal of binary tree iteration class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> res; if (!root) return res; stack<TreeNode *> stk; while (root || !stk.empty()) { ...

Posted by PHPnewby! on Tue, 04 Jan 2022 06:35:53 +0100

Basic algorithms for arrays

1. Find the subscript of the last deleted element There is an array a[1000] to store 0-999. It is required to delete one number every two numbers, and cycle to the beginning at the end to continue running. Find the original subscript position of the last deleted number. Take 8 numbers as an example: {0,1,2,3,4,5,6,7}: 0 - > 1 - > ...

Posted by damianjames on Tue, 04 Jan 2022 06:26:50 +0100

95% of the algorithms are based on these six algorithms

The algorithm idea is the core to solve the problem. The tall buildings rise from the flat ground, which is also true in the algorithm. 95% of the algorithms are based on these six algorithm ideas. This paper introduces these six algorithm ideas to help you understand and solve various algorithm problems. 1 recursive algorithm 1.1 algorithm s ...

Posted by hughesa on Tue, 04 Jan 2022 05:20:38 +0100

[learning notes] [Leetcode explanation by category] - linked list

Linked list related summary The chain list problem is very easy to make mistakes. Please be sure to draw the process on the paper first. Please tear it by hand and draw a schematic diagram Virtual head node + iteration + recursion The main types of linked lists are: single linked list, double linked list and circular linked listStorage mode o ...

Posted by daxxy on Tue, 04 Jan 2022 05:04:06 +0100

Borderline smote algorithm introduction and Python implementation [source code attached]

💖 About the author: Hello, I'm brother cheshen, cheshen at No. 18 Fuxue road 🥇 ⚡ About - > Che Shen: the fastest time from the bedroom to the laboratory is 3 minutes, and the slowest time is 3 minutes and a half (that half minute is actually waiting for the traffic light) 📝 Personal homepage: A blog that should have no place to live_ Che ...

Posted by alcapone on Tue, 04 Jan 2022 04:19:56 +0100

Data structure - heap

Heap Heap is a special kind of data structure in computer science. Heap can usually be regarded as an array object of a complete binary tree.Heap classification: the heap with the largest root node is called the maximum heap or large top heap, and vice versa is called the minimum heap or small top heap. Common heaps include binary tree heaps, ...

Posted by Sorrow on Tue, 04 Jan 2022 04:10:43 +0100

[advanced 3] Python implementation (MD)HFVRPTW common solution algorithm -- differential evolution algorithm (DE)

Based on python language, the classical differential evolution algorithm (DE) is implemented to solve the vehicle path planning problem (MD) HFVRPTW) with constraints such as multi depot, heterogeneous fixed fleet and service time window. Previous information python implements six intelligent algorithms to solve CVRP problemspython impl ...

Posted by Vanness on Tue, 04 Jan 2022 03:58:29 +0100

[training question 47: probability dp | dynamic programming | optimization] Increasing Subsequence | 2021 Niuke summer multi school training camp 1 question I

meaning of the title Increasing subsequence 2021 Niuke summer multi school training camp 1 Count Reg n n Array of n, No i i i number is ...

Posted by Rowno on Tue, 04 Jan 2022 03:00:12 +0100

[daily force deduction 15] effective letter words

1, Title [LeetCode-242] Given two strings s and t, write a function to determine whether t is an alphabetic ectopic word of s. Note: if each character in , s and t , occurs the same number of times, then , s and t , are called alphabetic words. Example 1: Input: s = "anagram", t = "nagaram" Output: true Exa ...

Posted by sebjlan on Tue, 04 Jan 2022 02:50:46 +0100

Python machine learning -- clustering algorithm -- K-means(K-means) algorithm

Types and introduction of K-means algorithm Unsupervised learning clustering algorithm; Clustering algorithm is an unsupervised algorithm, and K-means is a clustering algorithm; Definition of K-means algorithm The so-called clustering problem is to give an element set D, in which each element has n observable attributes, and use some algori ...

Posted by skypilot on Tue, 04 Jan 2022 02:32:51 +0100