Legendary Baidu pen questions

Source: Internet
Author: User

I. multiple choice questions: 10 questions in total at 15 points
1. A linear table (,) is known, and the hash function used is hash ($ key) = $ key mod 7, hashed elements to a hash table with a table length of 7 for storage. Select the average length, zipper method, and linear detection method of the Equi-probability successful search applied to the hash list respectively.
A. 1.0 B. 1.5 c. 1.7 D. 2.0 E. 2.3
F. 7/6G. 4/3 H. 3/2

2. You need to refresh the OS buffer data to the hard disk. You can call the following functions ):
A. fflush () B. fsync () C. Sync () D. writev ()

3. Which of the following shell statements cannot print the path of the user's main directory?
A. Echo "$ home" B. Echo ~
C. Echo '$ home' d. Echo $ home

4. In the worst case, the number of comparisons required to merge two sorted arrays whose sizes are n
A.2n B .2n-1 c.2n + 1 d.2n-2

5. The subnet mask of a Class B network is 255.255.240.0. the maximum number of hosts that a subnet can possess is:
A. 240 B. 255 c.4094 D. 65534

6. After the following code is executed, the Val value is ___:
Unsigned long Val = 0;
Char a = 0x48;
Char B = 0x52;
Val = B <8 |;
A 20992 B 21064 C 72 D 0

7. The memory speed is much higher than the disk speed. To solve this problem, you can use:
A parallel technology B virtual memory technology c Buffer technology D Channel Technology

8. The following code prints the result (assuming it runs on an i386 series computer ):
Struct st_t
{
Int status;
Short * pdata;
Char errstr [32];
};

St_t st [16];
Char * P = (char *) (St [2]. errstr + 32 );
Printf ("% d", (P-(char *) (ST )));

A 32 B 114
C 120 d 1112

9. threads in the same process can share the following
A. Stack B. Data Section
C. Register set D. Thread ID

10. Which of the following operations is most suitable for sorting first?
A. Find the maximum and minimum values. B. Calculate the arithmetic mean value.
C. Find the median. D. Find the value that appears most frequently.

Ii. Short answer: 20 points for a total of 2 questions

1. (6 points) the following is an HTTP request:
GET/Baidu/blog/item/6605d1b4eb6433738ad4b26d.html HTTP/1.1
HOST: hi.baidu.com
User-Agent: Mozilla/5.0 (windows; U; Windows NT 5.1; ZH-CN; RV: 1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
Accept: text/XML, application/XML, application/XHTML + XML, text/html; q = 0.9, text/plain; q = 0.8, image/PNG ,*/*; Q = 0.5
Accept-language: ZH-CN, ZH; q = 0.5
Accept-encoding: gzip, deflate
Accept-charset: gb2312, UTF-8; q = 0.7, *; q = 0.7
Keep-alive: 300
Connection: keep-alive
Referer: http://hi.baidu.com/baidu
COOKIE: baiduid = afb70e986ac48b336abab7505cdd1c76;

Please explain the basic meanings of the following fields: Host, User-Agent, accept-charset, connection, Referer, cookie

2. (14 points) function a converts str1 to lowercase and prints the string before and after conversion. In addition, the function interfaces and main ideas cannot be changed during the error correction. Indicate the row number when you change the value.
1 # include <stdio. h>
2 # include <stdlib. h>
3
4
5 char * str1 = "abdfljlero we are all SAF ";
6
7 char * tolower (char s [])
8 {
9 static size_t I = sizeof (s );
10
11 For (I; I> = 0; I --){
12 if (s [I]> "A" & S [I] <"Z "){
13 s [I] + = 26;
14}
15}
16 return S;
17}
18
19 int ()
20 {
21 printf ("Old STR [% s] After lower [% s] n", str1, tolower (str1 ));
22}

Iii. programming questions: 30 points total 1 question
Note: complete code is required. If you can compile and run the code, add additional points as appropriate.

1. Two sorted integer arrays, intersection, and fastest Algorithm
Input: two sorted integer arrays (int A [m], B [N])
Output: intersection of two Arrays

Iv. Design Questions: 35 points total 1 question
Note: Describe your data structure, system architecture, and design ideas as much as possible. We recommend that you write more pseudocode or process instructions.
1. consider a string replacement process. A text file contains some text content and some variables to be replaced. The variable format is "$ var $ ", the original "$" uses "$" for escape. The original "$" is "$ ". The file containing variables is called a template (the file name is T), and the average length of the text file is 100 K. In addition, there are a series of variable files, which correspond to the variable name and variable value (the file name is 1.v, 2.v... N. V), the number of variables contained in each variable file is in the order of millions, and the variable order is not fixed. We need to replace the variables in the template with the variables in the variable file, and write the generated files as (1.r, 2.r... N. R ).
Requirements: optimize the program in terms of algorithm and implementation and technical details, and make the program as efficient as possible. The running environment is 2 GB memory and 4 CPUs. Clarify the main ideas, give the pseudo code and description, and highlight the optimization technology you are using.
Example: The template file is
This is an $ FF $. I like $ FF $ and $ Fa $.
The variable file is
1. v
FF: banana
Fa: Apple
2. v
Fa: Apple
FF: bananas
The generated file is
1. r
This is an banana $. I like banana and apple.
2. r
This is an banana $. I like bananas and apples.

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.