2015 Baidu school recruitment test Hangzhou Station

Source: Internet
Author: User

1: Describe the difference between stack and queue in the data structure. And state three operations.

A: The stack is advanced and later available. The queue is FIFO. For example, (POP () Push () Empty () Back () Front ());

2: Please describe the polymorphism in C ++. For example:

I learned Java. But I remember the polymorphism should be reload and rewrite.

Overload Class A {int Foo (int A) {...} int Foo (int A, int B ){...}}

Override Class A {int Foo (int A) {return a} Class B: A {int Foo (int A) {return-}}

3: Please describe TCP four waves. In addition, let's talk about the role of time_wait.

I drew the correct picture of the four waves. But the package name is garbled... Time_wait I thought it was a waiting time. When the time is reached, it will be disabled by default...

Online answer: 1. Prevent the packets in the last connection from appearing again after they get lost, and affect the new connection (after 2msl, all the repeated packets in the last connection will disappear) 2. The reliable closing of the TCP connection may be lost in the last ack (FIN) sent by the active closing party. In this case, the passive party resends the fin. If the active Party is in the closed state, it will respond to RST instead of ack. Therefore, the active party must be in the time_wait state, not the closed state. Time_wait does not occupy a large amount of resources unless it is attacked. Also, if one side sends or Recv timeout, it will directly enter the closed status

2. programming questions

1: write a program that can flip words in the entire article. No function is allowed. I will not talk about this ACM question bank.

2: longest incrementing subsequence:

This question was dumb on the spot. However, the impression is that DP uses LCS. Later, I was dumb. Brute force...

In fact, the source string is sorted using the sorted string and the source string for LCs. Silly


3: Write a finite state machine. Obtain all the annotations in C ++ code.


3. System Design: when the number of simultaneous online users is 0.1 billion. The program should be able to update the game ranking at any time, and the user should be able to find their own ranking.

My design:

1: Design a hash algorithm based on the user ranking. Map the data of 0.1 billion million users to 1 million files. In this way, each file has users. Add a ranking index to the file.

2: read/write splitting. The storage and read systems are separated into two parts.

3: When reading data, the user first finds the ranking file of the user's current score based on the index. Then query in the file.

4: storage, because the storage is not particularly well controlled. After the file is inserted, the indexes of all files are updated. However, a file may become very large. Split the file when the number of users of one file reaches.


Note: The above is not necessarily correct. But I think I am an undergraduate at the dregs University. It would be nice to have a written test with so many graduate students in one test room. Continue looking for work ing ....

2015 Baidu school recruitment test Hangzhou Station

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.