Strategy mode and responsibility chain mode

1, Strategy mode Strategy Pattern, also known as policy pattern, encapsulates the defined algorithm families and so that they can be replaced with each other, so that the change of the algorithm will not affect the users using the algorithm. It belongs to behavioral mode. Define a family of algor ithms, encapsulate each one, and make them ...

Added by dansk on Sun, 19 Sep 2021 17:09:23 +0300

The problem of clockwise rotation m times of n-order matrix in Java

preface Today, I took part in a written test and came up with this question. I didn't do it in the end. It's a real dish. After the written examination, I thought again and finally realized the requirements of the topic subject The requirements of the topic are as follows (I can't remember): First enter an integer n, the range seems to be [ ...

Added by jeva39 on Sun, 19 Sep 2021 15:36:03 +0300

[PAT grade a review] topic review 9: mathematics related

Topic review 9 (9.10): mathematics related 1 maximum common divisor and minimum common multiple Code of maximum common divisor: int gcd(int a, int b){ if(b == 0) return a; else return gcd(b, a%b); } lcm(a,b) = a / gcd(a,b) * b; //Least common multiple 2 representation of scores Extra attention should be paid to division. If t ...

Added by Naki-BoT on Sun, 19 Sep 2021 14:23:01 +0300

Data structures and algorithms

#Data structure and algorithm Introduction Logical structure Physical structure Talk about algorithm Algorithm time complexity Just tell you to pay attention to the highest order, then ignore the constant product of constant and order, and pay attention to enough data. The number of executions is ...

Added by Ryan0r on Sun, 19 Sep 2021 12:49:19 +0300

Dynamic programming problem

1. Stair climbing: there are n stairs in total. You can only climb 1 or 2 stairs at a time. How many methods are there to climb n stairs? Idea: assuming there are 10 stairs in total, when completing the 9th stair, you can complete the 10th stair by going up one step. When the 8th stair is completed, it can also be completed by going up the 2nd ...

Added by Arenlor on Sun, 19 Sep 2021 11:04:22 +0300

Algorithm learning recursive algorithm

Application conditions This blog summarizes and reflects on the MOOC course of data structure and algorithm by Chen Bin of Peking University. Recursion is an elegant way to understand problems, and it is also a place where I was confused in the process of learning. To understand recursion, keep in mind the three elements of recursive app ...

Added by goosez22 on Sun, 19 Sep 2021 08:34:52 +0300

Linux Advanced Application multithreading programming

1, Why multithreading? else if(60<xy.x && xy.x<300 && 240<xy.y && xy.y<300)//Enter LCD detection { printf("enter LCD checking\n"); while(1) { lcd_show_color(RED); xy = get_ts_xy();//block else if(700<xy.x && xy.x<800 && 0<xy.y && xy.y<50)// ...

Added by love_php on Sat, 18 Sep 2021 16:58:47 +0300

Data structures and algorithms - linear search - binary search

This article is an original article of Joshua 317. Please note: reprinted from Joshua 317 blog Data structures and algorithms - linear search - binary search - Joshua 317's blog 1, Binary search description Binary Search, also known as Binary Search, requires the data sequence to have a linear structure, that is, the sorted data sequence. For ...

Added by Stalingrad on Sat, 18 Sep 2021 16:40:24 +0300

Nonlinear optimization -- Application of NLopt algorithm and C + + Example

Before reading this article, I suggest reading it first This article , it talks about the principle of nonlinear optimization, that is, the concept of related terms, and then introduces the use method of NLopt, which is based on C language. This film introduces an example of NLopt in C + + language. Before the example, first introduce the ...

Added by mrjap1 on Sat, 18 Sep 2021 09:17:58 +0300

Monotone stack and monotone queue

Directory QWQ Monotone stack and monotone queue abstract Monotone queues and monotone stacks require monotone elements on the basis of ordinary queues and stacks. In fact, the application of monotone queues and monotone stacks is also based on their monotonicity. In fact, I don't think the difference between these two special data struc ...

Added by gregtel on Sat, 18 Sep 2021 09:10:23 +0300