MindMap Gallery Algorithm and program implementation
This mind map of algorithms and program implementations organizes the content of algorithms and algorithm descriptions, basic knowledge of programming languages, commonly used algorithms and their program implementations. Come and take a look!
Edited at 2023-03-05 11:01:34One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
Project management is the process of applying specialized knowledge, skills, tools, and methods to project activities so that the project can achieve or exceed the set needs and expectations within the constraints of limited resources. This diagram provides a comprehensive overview of the 8 components of the project management process and can be used as a generic template for direct application.
One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
One Hundred Years of Solitude is the masterpiece of Gabriel Garcia Marquez. Reading this book begins with making sense of the characters' relationships, which are centered on the Buendía family and tells the story of the family's prosperity and decline, internal relationships and political struggles, self-mixing and rebirth over the course of a hundred years.
Project management is the process of applying specialized knowledge, skills, tools, and methods to project activities so that the project can achieve or exceed the set needs and expectations within the constraints of limited resources. This diagram provides a comprehensive overview of the 8 components of the project management process and can be used as a generic template for direct application.
Algorithm and program implementation
Algorithms and algorithm descriptions
Algorithm concept
Generalized: Algorithm is the steps and methods used to solve a certain problem within limited steps.
Computer Science: A series of computational steps
Characteristics of algorithms
Finiteness
certainty
feasibility
There are zero or more outputs
has one or more outputs
Description of algorithm
natural language
Benefits: easy to understand
Disadvantages: Seems verbose, expression is not intuitive and clear enough
flow chart
Benefits: Intuitive, clear
Disadvantages: It is large and difficult to modify
pseudocode
Benefit: Easier to be converted into programming language
Basic control structure of the algorithm
sequential structure
A top-down structure that executes each step in the algorithm sequentially.
branch structure
Also called a selection structure, it is a structure that makes judgments based on given conditions and then performs different operations based on the judgment results.
Note: The judgment box: one in and two out. The entire branch structure: one in and one out.
Loop structure
The loop structure is also called a repeating structure, which is a structure that repeatedly performs a certain part of the operation based on conditions. This part of the operation that is performed repeatedly is also called the loop body.
Current loop: first determine the condition, then execute the loop body. The loop body may not be executed even once
Until loop: execute the loop first, then judge the condition The loop body is executed at least once
Become a problem-solving process
Abstraction and Modeling
design algorithm
Programming
Commissioning
Basic knowledge of programming languages
Programs and Programming Languages
machine language
Machine language is a set of machine instructions identified by binary code that can be directly recognized and executed by the computer.
An instruction is a statement in machine language
Benefits: Ability to directly identify and execute Disadvantages: Poor readability and compatibility
Assembly language
Replace the opcodes of machine instructions with something like English abbreviations Use address symbols or labels to replace the addresses of instructions or operands, and then convert them into machine language at runtime
Benefits: Highly readable, fast Disadvantages: Cannot be executed directly, poor compatibility
high level language
Based on daily human language, expressed in words that are easy for ordinary people to accept
Benefits: easy to write, high readability, does not depend on the hardware system
Python commonly used data types
integer
Identifier: int
floating point
Identifier: float
It consists of an integer part and a decimal part, and can also be expressed using scientific notation.
string type
Identifier: str
A string of characters enclosed in single quotes (‘’) or double quotes (“”)
boolean
Identifier: bool
There are only two values: True or False, which are often used in logical judgments.
Constants, variables and assignment operators in Python
constant
It is directly given and refers to a quantity that does not change during the running of the program.
variable
Refers to the amount that can be changed while the program is running.
Naming rules: composed of uppercase and lowercase English letters, numbers or underscores, with English letters or an underscore as the first character, no limit on length, cannot have the same name as a Python reserved word, case sensitive
Assignment operator
The assignment symbol in "for Python" is to change the right side of the assignment number The evaluation result of the expression is stored in the variable specified to the left of the assignment number.
Note: Assign value first and then use it. Assignment means overwriting.
Operators and expressions in Python
arithmetic operators
Addition, operator " ", priority "3"
Subtraction, operator "-", priority "3"
Multiplication, operator "*", priority "2"
Division, operator "/", priority "2"
Remainder, operator "%", priority "2"
Power, operator "**", priority "1"
Integer division, operator "//", priority "2"
Relational operators
Equal to, operator "==", for example (a=10, b=20) a==b, returns false
Greater than, operator ">", a>b, returns false
Less than, operator "<", a<b, returns true
Greater than or equal to, operator ">="a>=b, returns false
Less than or equal to, operator "<=", a<=b, returns true
Not equal to, operator "!=", a!=b, returns true
Logical Operators
Not, operator "not", priority "1", not (a==b), if a and b are equal, return false, otherwise return true
And, operator "and", priority "2", a and b, the result is true only when a and b are both true.
Or, operator "or", priority "3", a or b, as long as either a or b is true, the result is true
Built-in functions and module imports in Python
float(3) converts integer data 3 to a floating point data, which is 3.0
int (3.6) Convert floating point data 3.6 into an integer data, which is 3
abs(3), returns the absolute value of x abs(-8)=8
round(a,b) rounds a to keep b digits round(3.1415,2)=3.14
pow(a,b), returns the result of a raised to the power b pow(2,10)=1024
str(3) Convert integer data 3 to string data, which is ‘3’ or “3”
Strings in Python
Operation "x y", description "Concatenate two strings x and y"
Operation "x*n", description "copy string x n times"
Operation len(x), description "returns the length of string x"
Lists in Python
Method: list.append(x), description: append member x to the end of the list
Method: list.insert(i,x), Description: Insert x into the specified position i in the list
Method: list.remove(x), Description: Delete the specified member in the list (if there are multiple, only delete the first one, if the specified member does not exist, an error will be reported)
Python implementation of sequential structure
1. Abstraction and modeling
2. Design algorithm
3. Write a program
4. Debugging and running
Python implementation of branch structure
single branch statement
Basic format: if conditional expression: statement block
double branch statement
if conditional expression: Statement block 1 else: Statement block 2
multi-branch statement
if conditional expression 1: Statement block 1 elif conditional expression 2: Statement block 2 … else: Statement block n
Python implementation of loop structure
Basic format of while statement
while conditional expression: statement block
The basic format of the for statement
for loop variable in sequence: statement block
range() function
range (1, 5, 3), description: Generate a sequence with a starting value of 1, a final value of 4, and a step size of 3: [1, 4]
range (1, 5), description: Generate a sequence with a starting value of 1, a final value of 4, and a default step value of 1: [1, 2, 3, 4]
range(5), description: Generate a sequence with a starting value of 0 (no starting value is set, the default is 0), a final value of 4, and a step size of 1: [0, 1, 2, 3, 4 】
range (5, 1, -1), description; generate a sequence with a starting value of 5, a final value of 2, and a step size of 1: [5, 4, 3, 2]
Commonly used algorithms and their program implementation
Basic principles of enumeration
Based on known conditions, within a given range for all possible The answers are listed and tested one by one in a certain order
Mode: 1. Determine conditions 2. Verification conditions
Program implementation of enumeration method