Common Algorithmic Framework

0 For any data structure, its basic operation is no more than traversal + access, and more specifically: add, delete, check and change. There are many kinds of data structures, but they exist for the purpose of adding, deleting, and altering as efficiently as possible in different scenarios. Is that not the mission of data structures? How to ...

Posted on Fri, 24 Sep 2021 12:25:26 -0400 by arcarocket

Segment tree template + some of my own understanding

After reading it many times, I finally understand something Because the left and right child nodes are often used, first define two functions to calculate the serial numbers of the left and right children: inline lc(int x){return x<<1;} //Left son inline rc(int x){return x<<1|1;}//Right son First, the segment tree uses each nod ...

Posted on Fri, 24 Sep 2021 08:37:21 -0400 by metrostars

Linked list theory based on Algorithm

1. Basic definition of linked list We have summarized the array of one of the two data structures before. This time, we will summarize the other - Linked List. Firstly, the bottom layers of dynamic array, stack and queue all rely on static array; Using resize to solve the fixed capacity problem may cause a lot of waste of memory space (f ...

Posted on Fri, 24 Sep 2021 08:04:08 -0400 by activeserver

[byte enterprise question bank] combination of linked list, two ordered linked lists, LRU cache mechanism, reverse linked list II [three questions a day]

Byte beating enterprise question bank and linked list series. Because leetcode members can see the enterprise question frequency, we brush from the highest to the lowest. There are 21 questions. Merge two ordered linked lists  , 146. LRU cache mechanism, 92. Reverse linked list II 21. Merge two ordered linked lists   [simple] [Title ...

Posted on Thu, 23 Sep 2021 18:34:04 -0400 by Jon12345

Graphic red black tree

Basic structure of red black tree   red black tree is a self balancing binary lookup tree. It is a data structure used in computer science. It is commonly used in associative arrays, dictionaries, etc. The internal data structure of Standard Association containers set, multiset, map and multimap in C + + is red black tree. Defini ...

Posted on Wed, 22 Sep 2021 13:48:23 -0400 by Wayne Herbert

7, Binary tree (12): balanced binary tree

Force button topic link (opens new window) Given a binary tree, judge whether it is a highly balanced binary tree. In this problem, a highly balanced binary tree is defined as a binary tree with each node   The absolute value of the height difference between the left and right subtrees of does not exceed 1. Example 1: Given binary tr ...

Posted on Wed, 22 Sep 2021 11:11:30 -0400 by chimp1950

⭐ Introduction to algorithm ⭐ Stack and queue simple 02 -- LeetCode 225. Implement stack with queue

1, Title 1. Title Description     please use only two queues to implement a last in first out (LIFO) stack, and support all four operations of ordinary stack (push, top, pop and empty). Implement MyStack class:    void push(int x): push element x into the top of the stack.    int pop(): removes and retur ...

Posted on Wed, 22 Sep 2021 09:29:37 -0400 by jariizumi

Data structures and algorithms: sorting

sort 1, Simple sort In our program, sorting is a very common requirement. We provide some data elements and sort these data elements according to certain rules. For example, query some orders and sort them according to the order date; Another example is to query some commodities, sort them according to the price of commodities, and so on. So, ...

Posted on Wed, 22 Sep 2021 08:42:02 -0400 by Darkpower

Four traversal methods of tree (recursive and non recursive implementation c++&java)

Traversal of tree: 1. Preorder traversal 2. Middle order traversal 3. Post order traversal 4. Sequence traversal 1. Preorder traversal         Preorder traversal, that is, DLR, first accesses the root node, then the left subtree, and then the right subtree. Therefore, traversal and backtracking are required Recursio ...

Posted on Wed, 22 Sep 2021 08:08:58 -0400 by pelleas

01Redis6-5 multiple data structure

1, Redis installation (1) Install GCC first yum install gcc (2) Unzip, - C /opt/module / and install it in the model directory. It's ok if you don't create the model directory tar -zxvf redis-6.2.1.tar.gz -C /opt/module/ (3) Enter the decompressed redis-6.2.1 directory and execute the command: make() is to compile the current redis file ...

Posted on Tue, 21 Sep 2021 23:07:42 -0400 by BDabrowski