Android interview (i)

Source: Internet
Author: User

1, talk about the difference between stacks and stack?

Stack (stack) is released by the compiler, storing the function's parameter values, local variable values, and so on, in the same way as the stack in the data structure (advanced).

Heap is usually assigned by programmers, if the programmer does not release, after the end of the program by the OS recycling, it and the data structure of the heap is two different, the distribution is similar to the linked list.

The heap in the data structure takes an array object instead of a linked list, which can be considered a complete binary tree, characterized by a parent node greater than (or less than) a value of two sub-nodes (called a large top heap or small top heap).

Full two fork tree: In addition to the last layer without any sub-nodes, all nodes of each layer have two sub-nodes, in short, each layer of the binary tree is full;

Nature:<1> Depth H (the number of layers with the deepest nodes in all nodes [the root node is the first layer]) = maximum number of layers K

<2> leaf node (number of nodes in K) is 2h (k)-1

<3> Summary points are 2k-1, and the sum of points must be odd

Complete binary tree: If the depth of the binary tree is H, outside the H layer, the nodes of the other "h-1" layers reach the maximum number, and all nodes of the H layer are continuously concentrated on the left.

Node Degree: The number of subtrees contained in the node.

The degree of the binary tree: the node with the largest number of subtrees in the two fork tree.

2. How many persistent links can be built between the two machines and why?

A specific connection we will use the same port number to identify, so the maximum number of connections will not exceed the number of ports the machine can specify.

Persistent connection, which means that there is no need to establish a new TCP (socket) connection for the delivery of each request object (such as a small GIF image), reducing TCP settling time and corresponding system losses.

Before using persistent connections, HTTP rules to obtain each URL resource requires a separate TCP connection, which increases the load on the HTTP server and causes Internet congestion.

Advantages of using persistent connections:

<1> reduce the number of TCP connections;

    <2> implements the pipelining of HTTP requests and responses on a single connection, which allows the client to send multiple requests without sending the next request after receiving an answer from the previous request, greatly reducing the time consumption;

<3> subsequent request delay reduction, without the TCP handshake is time-consuming, can be more fluent implementation of the HTTP protocol, due to the existence of persistent connections, the report error does not need to close the connection, so the client can use the latest protocol characteristics to make a request, if received a response that represents an error, swap the older semantics.

3, talk about the HTTP, HTTPS, WebSocket protocol understanding?

http: Hypertext Transfer Protocol, the most widely used network protocol on the network, is used to transfer hypertext to the local browser from the World Wide Web (www:world Wide Web) server. All WWW files must adhere to this standard, which was originally designed to provide a way to publish and receive HTML pages.

Advantages:<1> Simple and fast: The client transmits data to the server only needs to transfer the request method and the path, the common request method has the post, Get. Each method specifies that the server and the customer are in a different type of contact. Because the protocol is simple, the server program is small and communication is fast.

<2> Flexible: The HTTP protocol allows the transfer of arbitrary types of data objects. The type being transmitted is marked by Content-type.

<3> no connection: The meaning of no connection is to limit the processing of only one request per connection. When the server finishes processing the customer's request and receives the customer's answer, the connection is disconnected. In this way, the transmission time can be saved.

     <4> stateless: The HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory capacity for transactional processing. A lack of state means that if the previous information is required for subsequent processing, it must be re-routed, which may cause the amount of data to be transferred per connection to increase. On the other hand, it responds faster when the server does not need the previous information.

<5> support b/S and C/s mode.

Disadvantage:<1> communication uses plaintext (not encrypted) and may be tapped.

<2> does not verify the identity of the communicating party and may encounter a disguise.

<3> could not verify the completeness of the message and could be tampered with.

HTTPS: A security-targeted HTTP channel, in short, an HTTP security version. It solves the HTTP eavesdropping, easy to disguise, easy to tamper with the determination. Formula expression: HTTPS = HTTP + encryption + authentication + integrity protection.

WebSocket protocol: Is a protocol specification proposed by HTML5, the specification of a communication, through the handshake mechanism, between the client and the server to establish a similar TCP connection, convenient communication between the c-s. Before that, web interaction is generally a short or long connection based on the HTTP protocol. The WebSocket protocol is essentially a TCP-based protocol that creates a TCP connection for exchanging data after a special HTTP request is initiated through the HTTP/HTTPS protocol, after which the server communicates with the client in real time over this TCP connection.

  

  

Android interview (i)

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.