One article to solve the classic algorithm problem of linked list

Common questions about linked lists, such as: Get the last k element, get the element in the middle position, judge whether there is a ring in the linked list, judge the length of the ring, and problems related to the length and position. These problems can be solved through the flexible use of double pointers. Sword finger Offer 22 The ...

Posted by T2theC on Sat, 29 Jan 2022 20:39:08 +0100

Data structure - balanced binary tree (AVL tree)

preface First, let's think about an ordinary binary tree to save data. If you want to find a data, because the ordinary binary tree to save data is random, the time complexity to find the data is O(n). Back for convenience ,We also learn the binary search tree. Its definition is to put the number smaller than the root node on the left and ...

Posted by nmcglennon on Sat, 29 Jan 2022 20:34:12 +0100

Experiment 2 linked list experiment odd even number classification

Odd and even number classification based on linked list 1, Demand analysis 1. The data storage structure is linked list 2. The input form is keyboard, including numbers 1-9, spaces, and enter 3. The output form is print form 4. Contains the basic operations of the linked list 5. Be able to complete the sorting operation specified 6. It can se ...

Posted by onthespot on Sat, 29 Jan 2022 18:50:05 +0100

[data structure notes] B tree and B + tree, hash in STL_ Map and unordered_map container usage

B and B + trees B tree and B + tree are data structures used for external search, and they are balanced multi-channel search trees. The differences between the two are as follows: 1. In B + tree, the node with n keywords contains n subtrees, that is, each keyword corresponds to a subtree, while in B tree, the node with n keywords contain ...

Posted by dvdflashbacks on Sat, 29 Jan 2022 18:45:04 +0100

Operation of linked list in Linux system

Operation of Linux kernel queue This system imitates the queue implementation in Linux. It is a two-way linked list. Personally, I think the implementation of two-way linked list in Linux is simply wonderful. 1, Implementation of conventional linked list When learning the data structure course, they all learned the data structure of two- ...

Posted by o2cathy on Sat, 29 Jan 2022 18:16:41 +0100

7 questions to solve the binary search problem

The sequential array searches for a value The basic idea of binary search is that the search interval must be orderly In this paper, all search is based on the closed interval. At this time, the condition in while should be written as l < = R If you search by the open interval (r=nums.size()), the condition in while should be written ...

Posted by erax on Sat, 29 Jan 2022 17:59:15 +0100

Experience of learning red and black tree

Red black tree 0. Preface Recently, I saw a video of a red black tree in station b and thought it was very good. At the same time, I wrote down my experience after reading it. Video link: https://www.bilibili.com/video/BV135411h7wJ?p=15 Red black tree demo website: https://www.cs.usfca.edu/~galles/visualization/RedBlack.html be careful: T ...

Posted by Fallen_angel on Sat, 29 Jan 2022 16:45:25 +0100

Interval maintenance (tree array)

Problem Description: Title Description Problem solving ideas: The basic knowledge of tree array will not be repeated here. We only need to know that it can deal with interval maintainability and modifiable RMQ problems, which is more efficient. The following is the operation of segment tree Single point modification void update(int x,in ...

Posted by franknu on Sat, 29 Jan 2022 15:26:36 +0100

L2-018 polynomial A divided by B (25 points)

two L2-018 polynomial A divided by B (25 points) This is still A question about A/B, but both A and B are replaced by polynomials. You need to calculate the quotient Q and remainder r of the division of two polynomials, where the order of R must be less than the order of B. Input format: The input is divided into two lines. Each line gives ...

Posted by patmcv on Sat, 29 Jan 2022 07:35:06 +0100

Divide and conquer application is divided into search, quick sort and recursive sort

preface We all know that there are five commonly used classical algorithms: divide and conquer algorithm, greedy algorithm, dynamic programming algorithm, backtracking algorithm, branch and bound algorithm. Each algorithm plays a very important role in computer science; This article will introduce an implementation of the divide and conquer al ...

Posted by FireyIce01 on Sat, 29 Jan 2022 04:38:27 +0100