3.23 mock interview

Why C ++ destructor parent class virtual function must be

A: The first thing to know a knowledge that call subclass constructor call the parent class constructor call calling the parent class destructor class destructor will then polymorphic scenes If a parent class pointer to a subclass caused uplink conversion, this time to delete out of this parent pointer, will call the parent class destructor can not destructors out some subclass, and if it is a virtual function, then the destructor is actually a subclass of the call, then will which call the parent class destructor, the memory space can be realized fully released

 

 

Used ping Really, what protocol

A: ICMP protocols in the network layer

ICMP is a complex IP is a protocol packets often encounter various problems in the transmission time, ICMP protocol, then you can tell yourself what is wrong

ICMP error report is divided into packets and ICMP packets inquiry

Error report message is divided into: the end does not reach more than change the routing parameters of the problem 

Inquiry messages: echo request or answer, or to answer the request timestamp

 

 

You know syn flood attack? What treatment options do?

A: SYN flood: that is, in a DDos attack, the use of the TCP / IP protocol stack for the attack, which is the use of a large number of SYN requests to apply for a connection, the server at this time if ACK packet, then the answer, then the attacker will not be given reply, and then let the server has been in the semi-connected state consume server resources, although the TCP processing strategy is to wait for some time if there is no reply to give up the connection, but if a large number of requests time or enough resources at this time to the server the consumption of dead

  preventive solution:

    SYN cookie: use something like the serial number of the sender port to produce a cookie number to the sender, if the reply cookie + 1, then it is connected, or not connected, but also to calculate the cookie consume a lot of resources, it is not too much to force

    SYN proxy: is the use of a firewall, the firewall to the server instead of to bear these connections, a firewall sends the wrong serial number, if RST reply abnormal position, mark it can be connected, and then you can connect a server, or not, but this is actually that is, instead of using a high-performance firewall bear, if it reaches the peak of the firewall will still appear the same problem, it seems there is Huawei's "first packet drops + source address that identifies" the second will deal with this as the first packet is also discarded the first is to throw a bag, waiting to be sent over the end uh, did not look, do not know the line was not  

 

 

.https connection process, said this in great detail, asymmetric encryption, symmetric encryption, hash, certificate, handshake

answer:

 

 

 

 

c ++ copy of copy mode shades

A: shallow copy: that is simply passed by value, its value is assigned to it, but the problem arises when there are class pointer will cause two pointers to the same memory area, and cause errors

  Deep copy: no longer a simple value passed, first of all build together their first memory, and then deceives its value over

 

 

The difference between C ++, java's

1, Memory: C ++ can use the pointer to go directly to the operating memory, the memory must apply themselves to free himself, java garbage collection mechanism

After the first final compile all files are converted into binary code that the computer can only recognize binary, then different binary commands is not the same, so the code written on one operating system to binary: 2, platform independence , meaning the code and instructions may own imagination is not the same, C ++ is such, java, then compile it into two parts, front-end and back-end compiler compile front end compile the files become .class file, and then by a different jvm to convert complex class file into a binary file, so you can do an operating system written in code to run on multiple operating systems, the syntax is different from the number of operating systems are the same type byte of java, C ++ is not the case, bit 4 16 2 32 ..

 

 

 

What are the different ways of inter-process communication

answer:

1, pipes: anonymous and named pipes

2, the message queue

3, Semaphore

4, the signal

5, shared memory

6,socket

 

 

 

Handwriting algorithm problem, delete the list penultimate k nodes

answer:

Thinking: a pointer to the first let go of the k-th node, then again a beginning pointer, two pointers move simultaneously, and a pointer reaches the end of the other, the former is a pointer to the k-th countdown

 

struct node end_k (struct node h,int k){
      struct node *p=h,*q=h;
      for(int i=0;i<k;i++){
            q=q->next;    
      } 
     while(q){
          q=q->next;
          p=p->next;
    } 
    return p;
}    

 

 

 

 

 

 

Two special particularly large files, which are stored digital, digital found in both files are present. How to solve, try to give excellent algorithm

answer:

If the range of not: be a bitmap (bit_map), with one bit to represent the integer of whether there have been, as in C ++ the bitset, complexity of O (n)

If the range of a large low fault tolerance: Bloom filter can be used, is an evolution of the bitmap, the bitmap solved by limiting the size of the numbers, the first hash to a bucket, bucket inside each location is also a bit. O (n)

If the numbers are not large range of fault-tolerant: we can use hash partition, divided into hash for each file into multiple small files, and then two of the same small file hash lookup judgment, can look for two files are sorted , then O (n) process, or may be recorded map

The overall complexity of O (m * nlogn) m is the number of files, n being a digital amount of each file inside, will obtain the appropriate ratio of O (n) almost

 

 

 

new and malloc What is the difference?

A: If the call fails, then will be the first visit set_new_handle function user-implemented, generally the function is to release some useless memory, and then go try to apply, and then repeatedly calls this function until the application is successful, mainly to see how to function user-implemented

Then exit bad_alloc then throws an exception, the exception will direct the program to crash, so you can choose to not throw in the new (nothrow), or catch the exception using a try catch

 

 

Suppose there is a fan-attack skills, how to find all the enemies in the attack?

 A: I do not know, give the blog post again tomorrow to learn the whole look

https://www.cnblogs.com/miloyip/archive/2013/04/19/3029852.html

 

 

 100 coins, and a counterfeit money, counterfeit money with twice judge the real currency or heavy weight and ended

A: Because I have only twice, the first time I probably only know division counterfeit money on one side, the other side as a reference, let me into two piles 50, then light the pile into two piles 25, if two piles as heavy , indicating a pile of counterfeit money is certainly in there another 50 counterfeit money is heavy, if two piles of counterfeit money is not as important as that is in this pile of counterfeit money light

 

 

 

There are two stacks queue

A: a realization into a stack implementation and that if the current queue is empty, then the queue into all numbers are in the outgoing queue, then operation, complexity of O (n)

 

 

TCP flow control, sliding window;

A: Flow control is for the amount sent to both end hosts and adjusted, when the first three-way handshake will exchange the size of the sliding window is the number, then there will be a few pointers, divided into the sender receiving end, respectively, to be sent packet window has been sent to be confirmed, and the like to be received, and the like have fast retransmission mechanism, the sliding window is moved, then the packet is sent to the window

 

 

 

Quick sort is stable right? Why not stable?

A: unstable -

Examples of such a 23 (1) 3 (2) 3 (3) 1 (1) 1 (2) 1 (3) (thanks for example to cch Sponsors

1, it becomes the first round (3) 1 (2) 1 (1) 2 3 (3) 3 (2) 3 (1)

 

 

 

 

 

 

 
 
 

 

Guess you like

Origin www.cnblogs.com/Lis-/p/12555770.html