CSP-J / S knowledge Tap speak

CSP-J / S knowledge Tap speak

History and basic knowledge of informatics

First, informatics and computer history

  • Top awards computers : Turing Award
  • Information science have made outstanding contributions to the great God : Turing , von Neumann
  • China won the Turing Award great God : Yao (Tsinghua have Yao classes, is named after him)
  • The world's first computer : Eni Akbar (ENIAC), on February 14, 1946 was born at the University of Pennsylvania. Also called the tube computer.

Second, with regard to programming

  • Programming languages :

Divided into two categories: object-oriented and process-oriented.

  • High-level language and low-level language differences :

High-level language needs to be compiled to run, larger constant running slow. The constant low-level language is extremely small, fast. In addition, high-level language is more portable.

  • Common low-level language :

compilation

  • Level object-oriented language :

C ++, Java, EIFFEL, Simula 67 and so on.

  • Process-oriented high-level language :

C, Fortran language.

  • Recursive Programming :

Recursion refers to a repeat of the same problem into sub-problems and problem-solving methods. Recursive method can be used to solve a lot of problems in computer science. Simply put, it is "itself calls itself" (in function).

  • Class P / NP type / NPC kind of problem :

1, P class of problems: If a problem can find a solution to its algorithm in polynomial time, then the problem is the P problem.

2, NP kind of problem: Note: NP problem than the problem of non-P type , but a solution for the authentication problem in polynomial time. Or, we can be understood as a solution to guess the problem in polynomial time.

3, NPC kind of problem: is defined as follows: If a problem is NP, NP and all of the problems can be about it. Then it is NPC class of problems. Again introduce the definition of the reduced: if a problem can be reduced to about A problem B, meaning that this issue A solution can be used to solve the problem B.

Third, on the computer

First on Da map:

img

  • Important equipment :

    • Hardware components:
    1. Controller (Control): is the entire central nervous system of a computer, which functions to control the program information interpreted predetermined controlled according to their requirements, access schedule program, data, addresses, each part of the work and the coordinating computer memory and peripherals Wait.
    2. Operator (Datapath): arithmetic function is the data various arithmetic and logical operations, i.e. the data processing.
    3. Memory (Memory): function of the memory is to store programs and various data signals, command information, and provide this information when needed.
    4. The input device (Input system): the input device is an important part of a computer, an input device and an output device together referred to as external devices, referred to as peripheral action, a program input device is the original data, text, characters, or the control command field data collected information into the computer. Common input devices have a keyboard, mouse, optical input, tape drives, disk drives, CD-ROM machines.
    5. An output device (Output system): the input device and output device are also an important part of a computer, it outputs the information out of the outer intermediate results or the final result of the computer, various data or various control symbols and text in the machine signals . Microcomputer output device commonly the CRT display terminal, a printer, a laser printer, plotter, and a magnetic tape, CD-ROM drive and the like.
  • CPU and memory :

CPU (central processing unit) + = operator control register +

= + Memory internal memory external memory

BIOS is the English "Basic Input Output System" abbreviation, the Chinese name of the literal translation is "basic input output system." In fact, it is cured to a set of computer program within a ROM chip on the motherboard, which holds the most important program of the computer's basic input output system setting information, and the system of the POST program from the startup procedure. Its main function is to provide the bottom, the most direct and control the hardware settings for the computer.

Random access memory RAM "random" refers to a "readily accessible"

So, we write down the following knowledge:

After the power failure to store data: hard disk, ROM

Not after power saving data: memory (video memory), RAM, CPU

  • Each computer storage units and rounding :

Memory unit of the computer are the following:
$$
1TB = GB 2 ^ {10} = ^ {2} 20 is MB = 2 ^ {30} KB = 2 ^ {40} B
$$
carry between them 1024

Specially, 1B = 8bit, bit here is a case of a binary memory.


Decimal and hexadecimal conversion

Decimal turn any hex

N to convert decimal into binary, decimal numbers simply find each other than N remainder, then write out the remainder in reverse order.

Read on Figure:

img

This is a binary view of the other band on the analogy push it.

Any hex decimal turn

It simply is: Bitwise turn, the i-bit binary number is multiplied to convert the n-1 power can be.

Or on the map:

img

Arbitrary bases of mutual transformation

Here we consider doing relay decimal, hexadecimal A first decimal turn, Decimal and then to B band.

About hexadecimal conversion decimal

Decimal decimal decimal turn without any division, rounding is performed after the multiplication, the rounded front back arrangement.

Any fractional hex decimal turn only need to take on a negative index, calculated to last.

Letters each hexadecimal expression

H (Hexadecimal) - 16 hex

D (Decimal) - 10 hexadecimal

O (Octonary) - 8-ary

B (Binary) - 2-ary

Binary knowledge

Binary computer is a tool used for the calculation, naturally examination of the main points very often. There are many binary knowledge, even bit computing algorithm is binary content, but in order through the first round of preliminaries, we only introduce some theoretical knowledge. Knowledge about the bit operation Interested students own learning.

  • Original code

As the name suggests, after the original code is the binary coded decimal number into a binary converted directly formed directly.

  • Complement

Complement itself is positive, negative complement its anti-code plus one .

  • Inverted

As the name implies: positive anti-code per se, of the inverted negative result for all bits except the sign bit by bit inversion.

Attached: ASCII code

The formal name of the ASCII codes are: American Standard Code for Information Interchange , it is a set of computer coding system based on the Latin alphabet. Is the most common information exchange standards. It has defined 128 characters.

Here not assigned conversion table ASCII code. Only few of the more common given conversion:

Characters 0 → 48

Capital letters A → 65

Lowercase letters a → 97

Space → 32

Wrap → 13


logic operation

logic operation

There are three logical operators, each with two ways for writing:

Logical NOT :! Or ┐

Logical AND : && or ∧

Logical OR : or ∨ ||

Priority logic operations

Non> and> or

Bitwise logic operations priority +

Logical negation (!, ┐) = bitwise negation (~)> shift operations (<<, >>)> inequality sign (> =, <=)> equal sign (==,! =)> Bitwise AND (&) > bitwise exclusive oR (^)> bitwise oR (|)> logic (&&, ∧)> logical oR (||, ∨)

Logical expression

Composite formed by the logical operation, only two results: true and false, the value in C / C ++, the return to 0 for false, 1 for true.

Conditional expression

The basic form of the following conditional expressions:

<Expression 1>? <Expression 2>: <Expression 3>

Expression meaning is: if expression 1 is satisfied, the expression is executed 2, otherwise the expression 3. In fact equivalent to conditional if-else statements. For example:

#define Min(a,b) a<b?a:b

Note: If you have multiple conditional expressions composite, then the implementation of the time needed by the judge in order from left to finally arrive at a result. That is: the right binding .

such as:

<Expression 1>? <Expression 2>: <Expression 3>? <Expression 4>: <Expression 5>

Then, in the course of implementation it is from 3 to determine whether the true beginning, and then perform a certain expression, turn back up.


Knowledge of graph theory

basic concepts

  • FIG complete : any two sides are connected, it is easy to launch, the number of edges of a complete graph (n is the number of nodes) $ \ frac {n \ times (n-1)} {2} $
  • FIG communication : As the name suggests, is a connected graph of FIG communication, i.e., any two points can be directly or indirectly reaches, which is completely different from the defined edges with FIG must be directly reached.
  • Tree : that looks like a tree diagram. Definition is a simple path between any two points and only one. And a communication tree is acyclic FIG. It is the number of edges n-1.

Binary tree traversal

  • Preorder : traversal follows: root - left his son - the son of the right
  • Preorder : traverse the following way: the left son - root - Right Son
  • Postorder : traversal as follows: Left son - the son of the right - root

We use a diagram to understand what these types of traversal.

img

Preorder traversal of this picture: 1245367

Preorder: 4251637

Postorder: 4526731

  • A corollary :

    Preorder preorder + = one binary determined

    Postorder = a + preorder determined binary

    Preorder + = postorder what is not

Binary Tree and its special nature

  • Complete binary tree : Only the last one is not full, and the last one of all nodes are concentrated on the left.

Legend is as follows:

img

  • Full Binary : The number of nodes is full.

Legend is as follows:

img

  • Special binary nature :

1. For a full binary tree in terms of its leaf nodes is n, the total number of nodes is $ 2 \ times n-1 $. This conclusion is reversible.

2. For a full binary tree in terms of its number of layers (depth) as k, the total number of nodes it is $ 2 ^ k-1 $. This conclusion is reversible.


The basic theory of simple data structures

1. Stack

Imagine a bucket, you throw bricks inside from above, then you want a brick out, you need to acquire thrown out after you go to the brick. This is the stack. The basic principle is that the stack: LIFO

img

PS: before, during, postfix expression

A dedicated blog:

On the front, middle, postfix expression

2. Queue

Imagine you are in line to buy tickets, the ranks of these people are very quality, have to queue up and will not leave the team in advance. This will only be the first buying tickets and then leave from the team, the team from entering the tail. The basic principle is that the queue: FIFO.

Come out of icon:

img

3. list

List in two ways: one-way and two-way linked list linked list. On the list, I have devoted a blog. Interested readers please poke:

What is a linked list

List, by definition, is a table with a chain. I have already said, the list belongs to the enhanced version of the array. Then we can make use of an array of linked lists to understand: If the array is linked to a long line of "square", then the list is to put these boxes "opened", each box there are two arrows point to the front of the box the box and the back of the box.

So that we can understand why the linked list may support the random insertion and deletion. In a sense, each square here are discrete, we have a two inserted, just need to insert the elements, this element of the target position in front of the elements, the elements behind the arrow change it, I did insert operation. Delete empathy.

The principle of the list

The just understood, we can see that we can use to simulate a structure for each block, a structure of the memory element and two pointers, a pointer pointing to a position on the element and the next element. butKonjac pointer will notImplementation pointer is too much trouble, but when debugging is not very satisfactory. So we want to tell you is that the essence of a pointer position, then directed to "strengthen array" list is concerned, this position can be represented by what it?

Yes, array index.

Therefore, we have just the structure can be simplified, and becomes an element in the two variables int (memory array subscript). In this way, we will realize an array of analog linked list structure can be used.

Linked list implementation of the basic operation of the code

The essence of the list implementation is change pointer, get rid of the three elements (before, during and after) the list of legitimate pointer, to complete the operation we need to do, this section will not be too much to explain each piece of code, all of you to understand the meaning of the code, the best means of deduction pen and paper, will see more clearly some of the.

initialization

When we initialize the list, according to the first element of the process at the beginning of the title meaning, it is very important! And, we put all the pointers are cleared to -1, thus ensuring that the initial list is absolutely legitimate.

void init()
{
for(int i=1;i<=n;i++)
   a[i].pre=a[i].nxt=-1;
a[1].nxt=-1;
a[1].pre=0;
a[0].nxt=1;
}

Insert

void insert_left(int pos,int k)//把元素k插入到pos元素之前
{
a[a[pos].pre].nxt=k;
a[k].pre=a[pos].pre;
a[pos].pre=k;
a[k].nxt=pos;
}
void insert_right(int pos,int k)//把元素k插入到pos元素之后
{
a[a[pos].nxt].pre=k;
a[k].nxt=a[pos].nxt;
a[pos].nxt=k;
a[k].pre=pos;
}

Deletion

void remove(int x)
{
if(a[x].pre==-1)
   return;
a[a[x].pre].nxt=a[x].nxt;
a[a[x].nxt].pre=a[x].pre;
a[x].pre=-1;
a[x].nxt=-1;
}

Traversal

void print()
{
int start=a[0].nxt;
while(1)
{
   printf("%d ",start);
   if(a[start].nxt==-1)
       break;
   start=a[start].nxt;
}
}

Calculating temporal complexity

  • Time complexity : asymptotic time complexity represented by the symbol O. The number of executions of a program statement can be expressed in a algebraic expression, then we take the highest order terms in this algebraic and ignore this factor as a time complexity. If the number of executions of a program statement 2n ^ 3 + 3n ^ 2 + n + 7, then the asymptotic time complexity of this procedure is O (n ^ 3).
  • Non-recursive calculation program time complexity : simple and crude, the number of cycles.
  • Constant : constant is the time we ignore the O highest degree term coefficient and low order terms arising from consumption.
  • Space complexity : Analogue time complexity. Look how much open space open.
  • Calculate the amount of space occupied : According to our knowledge of the above mentioned computer storage units: an int is occupied by the memory 4B, so we open int multiplied by 4, is then divided by 1024 KB, empathy, and divide that MB 1024 .

Formula: n = number of elements, M being the final answer (in MB)

$M=\frac{4n}{1024\times 1024}$

PS: In general, given the game's memory can open a type of variable. In addition, large arrays must open global variables. If you throw in the main function very easily burst stack.


Mathematics, logic and operations research knowledge

  • Permutations : permutation and combination is compulsory knowledge points per year. But this is a big problem. Not only is the focus of elective sophomore math, is also an important branch of mathematical programming. About permutations and knowledge, I have devoted a permutation and combination of the blog, we invite readers to read:
  • Magic Squares

Permutations and Combinations

This essay to explain the more common informatics Olympiad one kind of questions - questions permutations and combinations. Read and understand Benpian essay asks the reader to have mathematical literacy is not less than a high school, and for information science recursion, deep search algorithm basic implementation, can understand the general recursive procedure.

1. permutations and combinations of definitions

Defined arrayed

From the n different elements, the selected m-th element in a row in a certain order, called a permutation of m elements taken from n different elements.

Definition of the arrangement

All arranged to select the number of m elements from n elements, the known number of permutations of m elements taken from n different elements.

Full array of definitions

When n = m all known arrangement of the whole arrangement .

Combination of the definition

From the n different elements, and selected elements m into a set, called a combination of m elements taken from n different elements.

Definition of the combination

Selecting the number of all combinations of m elements from n elements, the number of combinations is called the m elements taken from n different elements.

Permutation & combination distinction

In layman's terms, the combination regardless of order, are arranged sub-sequence, that is, to the number of columns 1, 2, there are the following two arrangements: 1,2 and 2,1, but only one or a combination of 1,2 2,1 .

2. Column & composition formula

About formulas arrangement

From the n different elements, the selected number of permutations of m elements, represented mathematically:. $ A_n ^ m $

Calculated as follows:

$A_n^m=n(n-1)(n-2)\cdots(n-m+1)=\frac{n!}{(n-m)!}$

Formula for the combination of

From the n different elements, the number of combinations of m elements selected mathematical expressed as:. $ C_n ^ m $

Calculated as follows:

$C_n^m=\frac{A_n^m}{m!}=\frac{n!}{m!(n-m)!}$

About full array formula

A number of columns of the whole arrangement number $ f (n) $, is calculated as follows:

$f(n)=n!$

3. The method of seeking the arrangement

Example: generating a full array

Given n, 1-n generates the full array.

We consider the use of recursion to solve the problem of the whole arrangement:

Recursive export when x == n + 1 to time, must not only equal to n! !

Our array using labeled recursive part and several column array implementation, the specific method can refer to the following:
img

Our recursive process is generally the following ideas:

Three digits 1-3. Each number may appear, so we use a recursive algorithm when the first delineation of this value, and then proceed to the next search, complete traversal of this "chain" when you look back on a digital still there is no other choice, thus ensuring understand do not leak.

Code examples:

#include<bits/stdc++.h>
using namespace std;
int n,a[20],v[20];
void dfs(int x)
{
    if(x==n+1)
    {
        for(int i=1;i<n;i++)
            printf("%d ",a[i]);
        printf("%d\n",a[n]);
        return;
    }
    for(int i=1;i<=n;i++)
    {
        if(v[i]==0)
        {
            a[x]=i;
            v[i]=1;
            dfs(x+1);
            v[i]=0;
        }
    }
}
int main()
{
    scanf("%d",&n);
    dfs(1);
    return 0;
}

Type Finish title

Questions Knowledge Point Type Topic number
Radio History Informatics & Basics 8-10
Radio C ++ grammar point 2-3
Radio Data Structure & Algorithms 3-4
Radio Mathematics & Logic & Operations Research 3-4
Radio Knowledge of the game 1-2
Problem Solving mathematics 1
Problem Solving data structure 1
Simulation program running C ++ syntax & Algorithms 4
Complete program C ++ syntax & Algorithms 2

Guess you like

Origin www.cnblogs.com/dengfull/p/11688802.html