2019-2020-1 semester 20,192,427 "Cyberspace Security Introduction," the fourth week of learning summary

Chapter VIII of abstract data types and subprograms

8.1 Abstract Data Types

1. abstract data types (Abstract Data Type, ADT): attributes (data and operations) clearly separated container and the particular implementation.

Container (container): store objects and other objects of the operation.

2. The design goal is to reduce the complexity by abstraction.
3. In the field of computing, it can be observed from the data the application layer, a logical layer, and these three layers to achieve.
4 relates to a data structure implementation layer.

Data structure (data structure): implement an abstract data type in the data fields of the composite.

8.2 Stack

1. The composite structure is an abstract stack, the stack can only be accessed from one end of the element. Elements can be inserted in the first place, or you can delete the first element.
2.Push (propulsion): insertion
Pop (pop-up): deletion
3. Stack does not attribute length, so there is no returning operation of the number of stack items.

8.3 queue

1. an abstraction queue structure, from one end of the queue items into, brought out from the other. REAR insert operation queue (tail) of the delete operation in the front of the queue (the head).
2.Enqueue, Enque, Enq, Enter and Insert can be expressed insert operation.
Dequeue, Deque, Deq, Delete and Remove can be expressed delete operation.

8.4 List

1. There are three attributes list characteristics: isomorphic project, the project is isomorphic, linear program, a list of variable length.

Linear: Each project has a unique addition to the first part before it, except the last one also has a unique part after it.

2. Do not list mistaken array, the array is embedded structure, the list is an abstract structure.
3. The list can also be into the image of the chain structure, chain structure is based on the concept of nodes.
4. A node consists of two parts: data and a list of points to the next node pointer of the user or a link. The last pointer variable node list is stored in a list indicating the end of the symbol, is typically null, with "/", respectively.

Chain structure (linked structure): at a position to save information to a data entry and find a method to achieve the same container.

8.5 tree

8.5.1 Binary Tree

1. Binary Tree (binary tree): having a unique starting node (root node) abstract composite structure, where each node may have two children nodes between the root node and each node has one and only one path.
2. root (root): tree only start node.
3. leaf node (leaf node): without children tree nodes.

8.5.2 binary search tree

1. The tree similar to an unordered list. To find an item in the tree, we have to check each node until you find the one you want, or do not find it in the trees.
2. binary search tree like a sorted list, semantic sort exist between nodes.
3. A binary search tree having a binary tree shape attributes, in addition, a binary search tree with semantic attributes to characterize further the value of the node tree, that is, any node must be greater than the value of all the nodes in its left subtree of value.
4. If the current point to a node, then the info (current) refers to the user data in this node, left (current) is the root node points to the left of the current sub-tree, right (current) points to the right child of the current root of the tree. null is a special value, indicating that pointer to null. Therefore, if a pointer is null, then the sub-tree is empty.

Clearly, the search for efficient binary search tree Yushu shapes are directly related.
Shape of the tree is inserted into the tree by the order determination program.

8.5.3 Other operations

1. binary search tree is actually a list of objects and have the same function, the difference between them is that the effectiveness of operations, and behavior is the same.
2. empty tree has a node 0, a tree has an arbitrary number of nodes plus the number of nodes and the right subtree of the left subtree.

Figure 8.6

1. The tree is an effective way to present architecture relations, that is, only a pointer to a node as much as its node (its parent). If this constraint is removed, we get another data structure - FIG.
FIG. 2. (graph): a set of nodes and a set of nodes that interconnect the data structure of the edge thereof.
Vertex (vertex): nodes in the graph.
Edge (arc) (edge (arc)): FIG vertex represents two connected nodes.
Pro vertices (adjacent vertice): two vertices are connected by edges.
Path (path): a list of vertices in the connection diagram two vertices.
3. undirected graph (undirected graph): FIG side where no direction.
Digraph (directed graph (digraph)): wherein edge is directed from one vertex to another vertex in FIG (or the same apex).

8.6.1 Create a map

Much of the information can be presented on the map: vertices, edges and weights.
Create a table requires the following:
• Add a vertex in the table
• add an edge in the table
• Add a weight in the table

Figure 8.6.2 Algorithm

1. depth-first search
when we tried to find a path between two vertices, with a stack to store vertex visit. First search to check first with the starting point with the neighboring vertices depth. If it is the end, the search ends. Otherwise, check all first vertex adjacent vertices. At the same time, we need to store the starting point and other neighboring vertices, then they will be used when needed. If a path starting from the first vertex and the adjacent starting point does not exist, then we return to the apex, try the second vertices, the third vertices, and so on.
2. BFS
breadth-first search, we want to go back to as far as possible, to find a path starting from the initial vertex. So the stack is no longer looking for a suitable data structure earlier path. We used to save the order of elements in the queue.
3. Single-source shortest search
the minimum number of strokes of the route does not mean that is the shortest total distance. Shortest traverse must be stated (and edge weights) a few kilometers between the cities during the search, rather than depth-first search and breadth-first search that. We want to retrieve from the current vertex nearest vertex, that is to say, while this vertex weights attached to the smallest vertex. We call this place the priority queue abstract container, retrieved element is the element that has the highest priority in the queue.

8.7 subroutine

1. Many routines are part of the high-level language or languages incidental library.
2.Insert operation requires a list and a value inserted therein.
3.Reset operations use a list to reset.
4.MoreItems operation requires a list to see if there are more elements waiting to be returned.
5.GetNext takes one input and returns a list of the next element in the list.
This information exchange is achieved through the concept of the argument list.

8.7.1 parameter passing

1. The list of parameters (parameter list): a communication mechanism between the two parts of the programs.
2. parameter (parameter): listed in parentheses after the name of the subroutine identifier.
3. arguments (argument): an identifier column in parenthesis subroutine call.
4. Referring can be shaped as a temporary identifier used in the subprogram. When the subroutine is called, the name of the real identifier unit will be sent to the subroutine call. The operation of the subroutine is defined parameter. When performing the operation, the arguments one by one alternative shape parameter.
5. When the subroutine is called, it will get a list of arguments (like the argument list written on a message board subroutine)

8.7.2 participation reference parameter value

1. There are two basic ways to pass parameters, i.e., passed by reference (or address) and passed by value.
2. The value of the parameter (value parameter): passed by the calling unit argument copy (write on the message board) of the parameter.
3. The reference parameters (reference parameter): arguments passed by the calling unit address (write the message board) of the parameter.
4. To access a reference parameter, the subroutine must access the contents of the address listed in the message boards. To access the value of a parameter, the subroutine only need access to the contents of the message board itself.

Summary
• lists, stacks, queues, trees and graphs are useful abstraction composite structure. Abstract composite structure has all the elements insertion and deletion of elements. Lists and trees as well as the search operation element in the structure.
• lists and trees have the same attributes: elements can be inserted, deleted and retrieval.
• lists, stacks, queues Netherlands are only a container structure, drawing more complex. A rich mathematical algorithms can be applied to the information in the spit. We pound explored three of them: breadth-first search, depth-first search, and single-source shortest path search.
• subroutine declaration so that the sub algorithm implemented independently.

                                                                                                   第九章 面向对象设计与高级程序设计语言

9.1 Object-Oriented Method

Object oriented design is to generate solutions to problems with independent entities called objects solving method, an object data by the operation and processing data configuration.
Object-oriented design is to focus on objects and their interaction problems. Once collected all the objects in question, they can constitute a solution to the problem.

9.1.1 Object-Oriented

1. Object (object): object or entity related problems in the background.
2. The object class (object class), or class (class): description of a set of objects with similar attributes and behavior.
3. domain (field): class specific item may be data or subroutines.
The method (method): defines the behavior of a particular class of algorithm.

9.1.2 Design methods
• decomposition process we have proposed four stages: brainstorming stage, filtration stage, stage scene, responsibility algorithm stage.

1. Brainstorm stage
identify problems in the first stage of class
2. Filter stage
review brainstorming stage to determine the class, to see which classes can be combined and which also lack class
3. stage scene
to determine the behavior of each class

Since each class is only responsible for their actions, so we call the class acts of responsibility.
Package (encapsulation): the data and operation together, and the logic operation of the attribute data and the separation of their implementation details.

4. Responsibility algorithm stage
to write algorithms responsibility of all classes will be listed.

CRC cards is the tool of such information at this stage to record.

5. Summary
object-oriented design focus is to convert the data object is generated as a result of the architecture of the object.

9.1.3 instance of a computer

Responsibility algorithm:
1.Person categories: There are two responsibilities need to break that initialization and output. Since the name is a class that allows these classes initialize itself and its own output. In object-oriented design method called routine is the method name of the object plus point number to be called together. [eg.name.initialize ()]
2.NAME Class: This class has two responsibilities, i.e., initialization and output, they are different algorithms. Initialization responsibility must prompt the user to enter a name, and the algorithm must read the names. Output responsibility must be output first and last name, and give appropriate label.

9.2 translation process

High-level language, we have to use other software tools to assist in the translation process.

9.2.1 Compiler

1. compiler (compiler): The translation program using high-level language into machine code.
2. To compile a program, it must have a version of this machine code compiler on a particular machine. Want the use of a high-level language in various types of machinery, it should have multiple compilers of this language.

9.2.2 Interpreter

1. Interpreter (interpreter): Enter the language written in high-level program, know the program a computer to perform the actions specified in each statement.
2. with the assembler and compiler output only in machine code and machine code execution alone is different, the interpreter executes the statement immediately after the translated sentence. It can be seen as an interpreter to understand programming languages emulator or virtual machine to use.
3. Second-generation high-level language can be divided into two, one is to be compiled, one is to be explained. FORTRAN, COBOL, and ALGOL are to be compiled languages; Lisp, SNOBOL4 and APL are to be interpreted language.
4. In order to achieve optimum portability, Java is compiled into a machine language standard - bytecode

Byte code (bytecode): compile the Java source code using a standard machine language.

The machine language is present as standard: one kind of JVM (Java Virtual Machine) is a software interpreter bytecode programs, called acceptance, and then execute it. In other words, the machine language byte code is not a specific hardware processor, any machine with a JVM can run Java programs compiled.

JVM: bytecode to execute the virtual machine programming.

9.3 programming language paradigms

1. paradigm:

  1. As the pattern or the model entities
  2. A set of assumptions, concepts, practice and values constitute a way to share their aggregate ++ ++ observation of reality, especially for mental discipline.
    2. There are two main paradigms, namely commands and statements, there are many in each of the sub-paradigm.

9.3.1 imperative paradigm

1.FORTRAN, BASIC, C, Pascal and C ++ are imperative paradigm.
2. The paradigm is characterized imperative execution sequence of instructions using the variables represents the memory address, and assignment of values for these variables used is changed.
3. The process-oriented paradigm:
process-oriented programming model is a command type, where statements are grouped into a subroutine. We write a subroutine to accomplish their function through the data needed to pass it.
4. The object-oriented paradigm
• object-oriented perspective of the object is a way to interact. Each object is responsible for the implementation of its own actions. In the process-oriented paradigm, the data is considered to be passive and is manipulated by a program.

• In the object-oriented paradigm, the data object is active. The operation code object and objects bound together, so that each object is responsible for control of their operation.

• SIMULA and Smalltalk is the first to support object-oriented programming language. Java and Python are two new object-oriented programming language.

9.3.2 declarative paradigm

Declarative paradigm is a model results described, it is not complete the process described results. There are two basic models in this paradigm: functions and logic.
1. Functional model: Based on the mathematical concept of functions. Calculation is achieved by evaluating the function call by the function is implemented, and second, to solve the problem.

The most common function paradigm languages Lisp, Scheme (Lisp language derived from a) and ML.
2. Logic Programming: Based on the principle of symbolic logic. This model includes a set of facts about the object and a set of rules on the relationship between objects. A program involve asking questions can be deduced by facts and rules to these objects and relationships.
3.PROLOG is the third generation logic programming language, contains three statements: a declarative fact that the relationship between objects and object; way of defining the rules of the relationship between objects and object; the third inquiry objects and objects of problem between relationships.
In PROLOG system, beginning with a lowercase letter constants, variables with an uppercase letter. In fact, we have a constant instead of a variable to inquire about the truth.

9.4 Advanced Functional Programming Languages

Two kinds of pseudo-code structure - selection and repetition (cycle) is a symbol of the command language.

9.4.1 Boolean expression

1. Boolean expression (Boolean expression): a sequence of identifiers, the compatibility between identifiers separated by operators, a value obtained formula true or false.
2. a Boolean expression can be:

  • A Boolean variable
  • An arithmetic expression plus a relational operators, coupled with an arithmetic expression
  • A Boolean expression plus a Boolean operator, plus a Boolean expression
    3 is a boolean variable address memory, referenced by an identifier stored true or false.
    4. Relational operators are operators to compare two values. The following table summarizes six relational operators and a variety of high-level language for representing their symbols:

symbol

meaning

Examples

Calculation rule

<Number1 less than <Number1 Number2 If less than Number2, is true, false otherwise
<= Less than or equal Number1 <= Number2 If less Number1 Number2, is true, false otherwise

Greater than Number1> Number2 if Number1 is greater than Number2, is true, otherwise false
= greater than or equal Number1> = Number2 greater than or equal if Number1 Number2, is true, otherwise false
! = Or <> or / = Number1 not equal! = Not equal Number2 if Number1 Number2, is true, false otherwise
= Number1 = Number2 or equal to == equal if Number1 Number2, is true, false otherwise

The two relational operator between two arithmetic expressions is to ask whether there is expression of the relationship between, for example: xValue <yValue is an assertion, i.e. less than xValue yValue. Indeed, if less than xValue yValue, then the result of the expression is true; xValue if greater than or equal yValue, then the result is false.

9.4.2 Data classification

1. strongly typed (strong typing): Each variable has a type, the only type of stored value to the variable.
2. The data type (data type): set of values and a description of this type can be applied to the value of the basic set of operations.
3. Most high-level languages are inherent to four data types, namely integers, real numbers, characters, and Boolean.

  • Integer: integer data type is represented by a range of integer values, this range is determined by the number of bytes represented by integer values. Some high-level languages ​​provide several different range of integer types, allowing the user to select the most appropriate type depending on the particular issue. It is applied to the standard operation of integer arithmetic and relational operators.
  • REAL: Real data type represents the range of the specified number of accuracy, as with the integer data type, this range is determined by the number of bytes of the real values. There are many high-level languages ​​real number two sizes.
  • Character: operation of the character is meaningless, but more character size is meaningful, it is possible to carry out operations on the relationship between the characters.
  • Boolean: Boolean data type has only two values ​​--true and false. Boolean variables can also specify a Boolean expression.
  • Integer, real, boolean and referred to as a simple data type or data type of atoms, because the value of each is independent, no longer divided.
  • String: a sequence of characters, in some languages, this is usually regarded as a sequence of data values.
  • We use single quotes circled characters, a string in double quotes circle. Some high-level languages ​​can adopt the same symbol circled characters and strings.

Statement (declaration): the statement variable, action or other entity identifier associated language, so programmers can refer to these projects by name.
4. reserved word (reserved word): word in a language having a special meaning, it can not be used as identifiers.
5.C ++, Java, python and VB.NET is case-sensitive.
6. The case-sensitive (case sensitive): uppercase and lowercase letters are considered different; two in the same spelling but different letter forms identifier is regarded as two different identifiers.
7.C ++ and Java statement ends with a semicolon. VB.NET is the use of a line or a comment section for the symbols to the end of the statement.

9.4.3 Input / Output Structure

9.4.4 Control Structure

1. The control structure (control structure): determining the order of execution of other instructions in the program.
2. Nested logic: statement is executed or skipped in any of the control may be a simple statement or block of statements (statement group), there is no limitation to these statements. In fact, it is skipped or repeated statement may comprise a control structure. Select statement can be nested loop structure. Nested loop structure can be selected in a statement. And selecting the sub-loop may be nested subroutine ah, subroutines can be nested loop structure or selection.
3. asynchronous processing: The program must identify the user clicks the mouse's behavior, then deal with the click continue. This type of processing is called asynchronous.

Induction (asynchronous): it does not occur simultaneously with other operations in the computer; in other words, the operation of the computer are not synchronized.
Asynchronous processing, also known as event-driven processing.

9.5 object-oriented language functionality

9.5.1 Packaging

1. Package (encapsulation): covert information embodiments language features.
2. The object class or classes (problem-solving stage) (object class or class (problem -solving phase)): Description of the properties and behavior of a similar set of objects.
3. Object (problem-solving phase) (object (problem-solving phase )): things or entity related to the problem background.
4. Object (realization phase) (object (implementation phase)) : an instance of class.
(Implementation phase) (class (implementation phase)) 5. categories: schema objects.

9.5.2 Class

Instantiate (instantiate): create an object class.

9.5.3 Inheritance

Inheritance (inheritance): class-based mechanism for acquiring other attributes (data fields and methods).

9.5.4 Polymorphism

Polymorphism (polymorphism): Inheritance architecture of a language with the same name has two methods according to the ability and is capable of applying the appropriate method of the object.

9.6 difference process design and object-oriented design

Summary
• object-oriented design focused on identifying problem objects, and in accordance with the properties and behavior of objects they abstract (packet) into classes.
• The assembler can translate assembly language programs into machine code.
• There are various models of high-level programming language.
• Boolean expressions are assertions about the state of the program.
• Each program has its own variable data types.

Guess you like

Origin www.cnblogs.com/lrz2427/p/11768563.html