Another Alibaba pen exam and another Alibaba exam
The next written examination... Various busy times...
1. If the key code K of an integer is hashed to a hash list with N slots, which of the following hash functions are good hash functions ()
A. h (k) = K/n B. h (k) = 1 C. h (k) = k mod N
D. h (k) = (K + random (N) mod N, random (N) returns an integer ranging from 0 to N.
2. In the following sorting algorithm, the rehearsal sequence of the initialized dataset has no effect on the algorithm performance ()
A, Heap Sort B, insert sort C, bubble sort D, fast sort
3. Which of the following statements is false ()
A. the CISC computer has more commands than the RISC computer.
B. In the instruction format, the purpose of adopting the extended operation code design scheme is to increase the addressing space to maintain the length of the instruction bytes.
C. Adding the data theoretical line of the pipeline segment can increase the CPU frequency.
D. The primary feature of the Von norm system architecture is the way stored programs work.
4. which does not belong to the necessary components of the proposed structure of the Von noimmann machine ()
A, cpu B, Cache C, RAM D, ROM
5. If the inbound stack sequence of A stack is a B C D E, the output impossible is ()
A, decba B, DCEBA C, ECDBA D, ABCDE
6. Do you think the programming language that can compile a C language compiler is ()
A, assembly language B, C, and VB language D.
7. Which of the following statements about static and object members in the C ++/JAVA class are true ()
A. static member variables are generated during object construction.
B. static member functions cannot be called in object member Korean.
C. The virtual member function cannot be a static member function.
D. The Static member function cannot access the static member variable.
9. A process needs to wait for data to be read from the disk during running ()
A, from running to blocking B, from running to ready C, from ready to running D, from blocking to ready
10. the time complexity of the following algorithm is ()
Int f (unsigned int n ){
If (n = 0 | n = 1 ){
Return 1;
} Else return n * f (n-1 );
}
A, O (1) B, O (n) C, O (n ^ 2) D, O (n !)
11, n starts from 1. You can add 1 to n or double n for each operation. To obtain an integer of 2013, you only need () operations.
A, 18 B, 24 C, 21 D impossible
12. If an undirected graph with n vertices is represented by an adjacent table, the size of the array containing the header node is () A, n B, n + 1 C, n-1 D, n + Edge Number
13. Consider a special hash function h, which can hash any string into an integer k with the probability P (k) = 2 ^ (-k), k = 1, 2, 3 .... The hash value of each element in the string set S of an unknown size is set to h (S ). If the maximum element maxh (S) in h (S) is 10, the expectation of S size is ()
A, 5 B, 10 C, 512 D, 1024
14. For the following function, the value of foo (2 ^ 31-3) in the 32bit system is ()
Int foo (int x ){
Return x &-x;
}
A, 0 B, 1 C, 3 D, 4
15. The time complexity of accessing nodes and adding and deleting nodes for Linear Arrays stored in sequence ()
A, O (n), O (n) B, O (n), O (1) C, O (1), O (n) D, O (1 ), O (1)
16. In A 32-bit system environment, the compilation option is 4-byte alignment, so sizeof (A) and sizeof (B) are ()
Struct {
Int;
Short B;
Int c;
Char d;
};
Struct B {
Int;
Short B;
Char d;
Int c;
};
A, 16,16 B13, 12 C, 16,12 D, 11,16
17. There are red balls, yellow balls, and white balls in the bag. If one is taken and put back each time, the probability is 8/9 () for three consecutive times ()
A. The color is all the same B. The color is not all the same C. The color is all different D. The color is not red.
18. The function of a shuffling program is to disrupt the order of n cards. Which of the following statements about Function Definition of shuffles is most appropriate ()
A. The probability that each card appears at n positions is equal.
B. The probability of each card appearing at n positions is independent.
C. The content of the two cards in any continuous position is independent.
D, N cards in any two different arrangement have the same probability.
19. Use two colors to dye the six flags in a circle. If it is obtained through rotation, it is only one type. Ask how many dyeing modes there are. A, 10 B, 14 C, 15 D, 16
20. recursively traverse a n-node binary tree with a depth of d. The size of the space to be searched is ()
A, O (n) B, O (d) C, O (logn) D, O (nlogn)
2. Option Selection
21. Two threads run on a dual-core machine. The main program of each thread is as follows: thread 1, x = 1; r1 = y; thread 2: y = 1; r2 = x. X and y are two global variables. The Initialization is 0. Which of the following is the possible values of r1 and r2 ()
A, r1 = 1, r2 = 1 B, r1 = 1, r2 = 0 C, r1 = 0, r2 = 0 D, r1 = 0, r2 = 1
22. Which of the following statements about linux LOAD is true ()
A. It is reflected by the number of ready and Running Processes
B. You can use the TOP command to view
C. You can view it through uptime.
D, Load: 2.5 1.3 1.1 indicates that the system Load is gradually decreasing.
23. Which of the following statements about sorting algorithms is false ()
A. The average time complexity of quick sorting is O (nlogn), and the fastest time complexity is O (n ^ 2)
B. The average time complexity of heap sorting is O (nlogn), and the fastest time complexity is O (nlogn)
C. The average time complexity of Bubble Sorting is O (n ^ 2), and the fastest time complexity is O (n ^ 2)
D. The average time complexity of Merge Sorting is O (nlogn), and the fastest time complexity is O (n ^ 2)
24. Assume that the rand_k function returns an integer (k> = 2) between [1, K] at random, and each integer has an equal probability. It is known that there are currently rand_7 implementations. Could you please call rand_7 and four arithmetic functions, and add control logic such as logical judgment and loop as appropriate ()
A, rand_3 B, rand_21 C, rand_23 D, rand_47
Iii. Fill in and answer questions
26. A cache system uses the LRU elimination algorithm. If the cache capacity is 4 and it is initially empty, when the following data items are accessed in sequence, 1, 5, 1, 3, 5, 2, 4, 1, 2, the number of direct cache hits is (), and the data items to be eliminated in the cache are ()
A: The number of direct hits is three, namely, when access is 1, 5, 1, 3, 5, 2, 4, 1, or 2. The data items to be eliminated in the cache are 5
27. There are two long one-way linked lists a and B. in order to find out that the node meets node in a and node in B, please design the algorithm with as little space as possible. (Can be expressed in C/C ++/JAVA or pseudo code)
A: node in a and node in B are the public nodes of the two linked lists.
That is, traverse the linked list A and linked list B respectively, write down the length of the linked list AB respectively, and check whether the last node of the linked list A and linked list B is the same at the end, if they are the same, there are public nodes. If they are different, there are no public nodes.
Looking for a public node is to use two pointers to find the first public node based on the length of the time history. The nodes are followed by public nodes.
28. When the storage data volume exceeds the data management capability of a single node, you can adopt a database sharding solution, that is, data is distributed and stored in multiple data management node N according to certain rules (node number 0.1.2... n-1 ). Assume that the stored data is a. Complete the program for data a computing and storage node. (If you have never learned C, you can also use the pseudo code)
# Define N 5
Int hash (int element)
{
Return element * 2654435761;
}
Int shardingIndex (int)
{
Int p = hash ();
// 1
Return p;
}
Space 1: p % = N;
29. Five students in the dormitory play the game together. Some players play the game as the Red Square and others play the blue square. How many games are required, so that any two people can have a red-square-to-blue match and a blue-square-to-red match?
The answer is 4.
Part 4: JAVA Selection
1. What are the output results of each of the following threads? (You only need to write the output result set without paying attention to the output sequence)
2. A text file with 1 billion records has been stored in order by keyword. Please design an algorithm to quickly search for keywords in the file.