Baidu 2014 Software Development Engineer)

Source: Internet
Author: User

Turn: http://blog.csdn.net/zs634134578/article/details/21387117

I. Short answer

1. Brief introduction to the 7-Layer Design of ISO

Resolution:

 

  1. Application Layer: provides inter-Application Communication
  2. Presentation Layer: processing data formats, data encryption, etc.
  3. Session Layer: establishes, maintains, and manages sessions
  4. Transport Layer: establishes an end-to-end connection to the host
  5. Network Layer: Addressing and Route Selection
  6. Data link layer: media access and Link Management
  7. Physical Layer: bit stream transmission

 

2. How to share data among multiple processes (write at least 3 types)

In Linux:

 

  • MPs queue
  • Semaphores
  • Shared Memory
  • Message Queue
  • Local socket

 

Windows:

  1. File ing and file ing (memory-mapped Files) enable the process to treat the file content as a piece of memory in the process address range. Therefore, the process does not need to use file I/O operations, and can read and modify the file content with simple pointer operations.
  2. Shared Memory: the shared memory (sharedmemory) in Win32 APIS is a special case of file ing. When creating a file ing object, the process uses 0xffffffff to replace the handle, which means that the corresponding file ing object accesses the memory from the file on the operating system page, other processes can open the file ing object to access the memory block. Because shared memory is implemented by file ing, it also has good security and can only run between processes on the same computer.
  3. Anonymous pipeline: pipeline is a communication channel with two endpoints: Processes with one end handle can communicate with processes with the other end handle. The pipeline can be one-way-one end is read-only, and the other end point is write-only. It can also be two-way. The two ends of a pipeline are both readable and writable.
  4. Named Pipe: The Named Pipe (Named Pipe) is a one-way or two-way channel for communication between server processes and one or more customer processes. Unlike an anonymous pipe, a named pipe can be used between unrelated processes and different computers. When the server creates a named pipe, a name is specified for it, any process can use this name to open the other end of the pipeline and communicate with the server process based on the given permissions.
  5. Mail slots: mailslots provides one-way communication between processes. Any process can establish a mail slot as a mail slot server. Other processes, called mail slot customers, can send messages to the mail slot server process by the name of the mail slot. The incoming message is kept in the mail slot until the server process reads it. A process can be either a mail slot server or a mail slot customer. Therefore, multiple mail slots can be established to implement bidirectional communication between processes.
  6. Clipboard: The clipboard (clipped Board) is essentially a group of functions and messages used to transmit data in Win32 APIs. It provides an intermediary for data sharing between Windows applications, the cut (copy)-paste mechanism established in Windows provides a shortcut for different applications to share data in different formats. When a user performs a cut or copy operation in an application, the application puts the selected data in one or more formats on the clipboard. Then, any other application can pick up data from the clipboard and select a suitable format from the given format.
  7. Dynamic Data Exchange: Dynamic Data Exchange (DDE) is a form of inter-process communication in which data is exchanged between applications in the shared content. Applications can use DDE for one-time data transmission, or dynamically exchange data between applications by sending update values when new data appears.
  8. Wm_copydata message: wm_copydata is a very powerful but little-known message. When an application transmits data to another application, the sender only needs to call the sendmessage function. The parameters are the handle of the destination window, the start address of the transmitted data, and the wm_copydata message. The receiver only processes wm_copy as it processes other messages.
3. Differences Between TCP and UDP

 

TCP

UDP

Ordered or not

The received data may be out of order, but there are segments for sorting.

Unordered

Reliability

Reliable

Unreliable

Connected?

Face-to-face connection

Non-connection

Responsible

Maintain virtual connections with high load

No connection, Low Load

Confirm?

Need to be validated (reliability)

No need to confirm

Controllable?

Sliding Window and congestion control mechanism

Uncontrolled


Ii. algorithm questions

1. There is a data a = [A_1, A_2, A_3... a_n]. The N size is not fixed. Please design an algorithm to combine all the data in a for output.

Resolution: it can be implemented by recursion. Each time an element is obtained, it is recursive in the array of the remaining elements. Pay attention to the conditions for Recursive termination.

 

2. there is such an array A, the size is N, the absolute value of the adjacent element difference is 1, such as a = {, 6, 5, 6, 7, 8, 9, 10, 9 }, given the array A and the target integer T, locate the position of T in. (15 points)

Resolution:

Solution 1: conventional solution: traversal, time complexity O (N)

Solution 2: Quickly locate the first target integer and traverse it later. The best case is O (1), and the worst case is O (n)

Quick Locating Method: Take a [0] <t as an example:

 

  1. Dis = T-A [0]. If a [dis] = T, locate,
  2. Otherwise, a [dis] Must be smaller than T. Repeat Step 1.

 

3. the area of the binary tree is equal to the length of the Binary Tree multiplied by the width of the binary tree. The width of the binary tree is equal to the distance between the longest nodes. The length of the binary tree is equal to the longest length from the root node to the child node, please design an algorithm to calculate the area of a binary tree?

Resolution: Area = length * width = depth of the tree * (depth of the Left subtree + depth of the right subtree + 1)

 

Iii. Algorithm Design Questions

There are many vertices to be labeled in Baidu map, and these vertices need to be described. The description is assumed to be a rectangle and can be on the left or right side of the vertex, but the vertex cannot be moved, if the description between two vertices is overwritten

Delete a vertex.

1. In a region, design an algorithm to output valid points (as many points as possible )?

2. If the area is large enough and there are enough points, the algorithm will encounter performance bottlenecks. Please design a detailed algorithm to describe and solve the problem?

Analysis: personal understanding

1. The key is how to solve conflicts between two points and how to adjust the conflicts.

 

  1. Mark from the upper left corner of the subway, line by line
  2. The default position is the right of the vertex.
  3. When a conflict occurs, check the responsibility points of the conflict region and ask if you can change them to left.
  4. If a conflicting point can reset the direction, it is reset. Otherwise, an inquiry action is also initiated until a point is successfully reset.

 

2. The performance bottleneck should occur in the adjustment algorithm. When a conflict occurs, it may cause a joint reaction, resulting in multiple adjustments.

Solution: classify points, add weights to each point, and mark points with higher weights by level.

 

Baidu 2014 Software Development Engineer)

Related Article

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.