Alibaba pen exam

Source: Internet
Author: User

1. There is a virtual storage system. If the process occupies three pages in the memory (the memory is empty at the beginning), if the first-in-first-out (FIFO) page elimination algorithm is used, how many missing pages will occur when the following access page number sequence is executed: 1, 2, 3, 4, 5, 5, 2, 2, 2, 3, 4, 5?
A, 7 B, 8 C, 9D, 10

2. There is an ordered stack S. Elements S1, S2, S3, S4, S5, and S6 are successively pushed to the stack, if the output sequence of the six elements is S2, S3, S4, S6, S5, and S1, what is the size of the ordered stack?
A, 2B, 3C, 4 d, 5

3. Which of the following statements about the file index structure is incorrect?
A. Using the index structure, logically continuous files are stored in consecutive physical blocks.
B. The system creates an index table for each file.
C. The advantage of the index structure is that the access speed is fast and the file length can be dynamically changed.
D. The disadvantage of the index structure is the high storage overhead.

4. [0, 2, 1, 4, 3, 9, 5, 8, 6, and 7] is the smallest heap stored in the form of an array, the result of deleting the heap top element 0 is ()
A, [2, 1, 4, 3, 9, 5, 8, 6, 7]
B. [1, 2, 5, 4, 3, 9, 8, 6, and 7]
C. [2, 3, 1, 4, 7, 9, 5, 8, and 6]
D. [1, 2, 5, 4, 3, 9, 7, 8, and 6]

5. In a page-based storage management system, the address register length is 24 bits, wherein the page number occupies 14 bits, the size of the main memory block is () bytes.
A, 10 B, 2 ^ 10 C, 2 ^ 14 d, 2 ^ 24

6. On a smooth and concave track with a length of 33 cm, each of the first, 3 cm, 6 cm, 19 cm, and 22 cm has a ball bearing. The concave track is very fine, you cannot use two balls at the same time. At the beginning, the ball movement direction is arbitrary. After the two ball balls collide, they move in reverse direction at the same speed. Assuming that the initial speed of all ball balls is 1 cm per second, the maximum time for all ball balls to exit the concave track is ()
A, 30 B, 26 C, 38 D, 33

7. Which of the following operators are reloaded by STD: vector: iterator?
A, ++ B,>
C, * (Front) d, =

8. Which of the following operators cannot be overloaded in C ++ ()
A, * B ,? : C,: D, delete

9. In the sorting method, the number of element comparisons is irrelevant to the initial arrangement of elements ()
A. Shell sort B. Merge sort C. Insert sort directly.
D. Select sorting
A and C are definitely not selected. The Merge Sorting is related to the sequence in merge. If the order is ordered, the number of comparisons is at least n/2, and the worst is that the elements are staggered to n-1. The number of sorted comparisons is irrelevant to the initial state of the keyword. The total number of comparisons n = (n-1) + (n-2) +... + 1 = N * (n-1)/2. So we should select sorting!

10. The following code is given: int X [4] = {0}; int y [4] = {1}; the values of array X and Y are ()
A}
B, {0, 0, 0}, {1, 0, 0}
C, {0, uncertain}, {1, uncertain}
D. compiler-related

10. Which of the following operations are valid?
Const char * P1 = "hello ";
Char * const P2 = "world ";
A, P1 ++ B, P1 [2] = 'W'; C, P2 [2] = 'l'; D, P2 ++

11. Assume that in the n-base system, the equation below is true. The N value is () 567*456 = 150216.
A, 9 B, 10 C, 12D, 18

Suppose it is in X notation, then 567 = 7 + 6 * x + 5 * x ^ 2,456 = 6 + 5 * x + 4 * x ^ 2, so 564*456 = (7 + 6 * x + 5 * x ^ 2) * (6 + 5 * x + 4 * x ^ 2) 150216 = 6 + x + 2 * x ^ 2 + 5 * x ^ 4 + x ^ 5, because 567*456 = 150216, 6 + x + 2 * x ^ 2 + 5 * x ^ 4 + x ^ 5 = (7 + 6 * x + 5 * x ^ 2) * (6 + 5 * x + 4 * x ^ 2). Finally, x = 18 is obtained.

12. Which of the following statements about struct and class are true ()
A. struct members are public by default, and Class Members are private by default.
B. struct cannot be inherited, and class can be inherited
C. Whether struct can have a constructor
D. The member variables of struct can only be public.

If it is not explicitly specified, the inheritance from class is handled by private inheritance, and the inheritance from struct is handled by public inheritance. Both public/private/protected modifiers can be used, with or without arguments.

13. Define a function pointer. the pointer to a function has two int parameters and returns a function pointer. The returned Pointer Points to a function with an int parameter and returns an int?
A, INT (* f) (INT, INT) (INT)
B. INT (* f) (INT, INT)
C, INT (* f) (INT, INT ))
D, * (* f) (INT, INT) (INT)

14. Declare a pointer to an array containing 10 elements. Each element is a function pointer. the return value of this function is int, the parameter is int *, and the correct value is ()
A. (int * P [10]) (int *);
B. Int [10] * P (int *);
C, INT (* P) [10]) (int *);
D. INT (int *) [10]) * P;
E. The preceding options are incorrect.

15. The input sequence of a stack is 123 ..... n. If the first element of the output sequence is N, the elements of output I (1 <= I <= n) are ()
A. Uncertainty
B. N-I + 1
C, I
D. N-I

16. Which of the following code will produce errors during compilation ()

# Include <iostream> using namespace STD; struct Foo {Foo () {} Foo (INT) {} void fun () {}}; int main (void) {Foo A (10); // statement 1A. fun (); // statement 2foo B (); // statement 3B. fun (); // Statement 4 return 0 ;}

A. Statement 1 B. Statement 2 C. Statement 3D. Statement 4
17. On a 32-bit machine

#pragma pack(2)class A{int i;union U{char buff[13];int i;}u;void foo() {    }typedef char* (*f)(void*);enum{red, green, blue} color;}a;

The value of sizeof (a) is ()

A, 20 B, 21 C, 22 D, 24 E, non-above options

18. Which of the following statements is false ()
A. The Public Member of the base class definition is visible in the derived class of the public inheritance and can be accessed outside the class.
B. The public and protected members defined by the base class are visible in the private inherited derived class and can be accessed outside the class.
C. The public and protected members of the base class definition are invisible to the inherited Derived classes.
D. The protected member of the base class definition is visible in the derived class inherited by protected and can be accessed outside the class.

19. When you insert or delete the middle part of the sequence frequently, you should select the container ()
A. VectorB. ListC, deque D, stack

20. The best way to determine whether a one-way linked list has a ring is ()
A. Duplicate traversal B, fast and slow pointer C, path record D, hash table assist
21. Here are the numbers 1, 2, and 3. You can use various operators in C. The maximum integer you can represent is ()

A, 2*3 * sizeof (1) B, 3 <(2 <sizeof (1) c, sizeof (3) <(sizeof (2) <(sizeof (1) d, (unsigned long) (2-3) * 1

The binary format of-1 is full 1 representation.

22. What is the output of the following code?

Class A {public: A () {cout <"A" <Endl ;}~ A () {cout <"~ A "<Endl ;}}; Class B: Public A {public: B (A & A): _ A () {cout <"B" <Endl ;}~ B () {cout <"~ B "<Endl;} PRIVATE: A _ A;}; int main (void) {A; // very simple, when defining a, a constructor B (a) is called ); // here, the _ A in B is constructed through the member initialization list // and the member object _ A of B is constructed through copy constructor, which is the default of the compiler, therefore, before constructing _ A, call the base class constructor // and then construct itself. The order is a ()-> _ A-> B () (partial) // Therefore, there are two, a B // perform structure before return /***************************** **************************************** * ** // * The structure is in reverse order of the defined objects, in addition, the same object is in reverse order of construction. Therefore, the structure B is then a, and the structure order of B is () -> _ A-> B () (partial). In turn, B () (partial)-> _- > A (), so what we get is ~ B-> ~ A-> ~ After B, A is the final result of structure ~ B-> ~ A-> ~ A-> ~ A */return 0 ;}

23. One dice, six faces, one is 1, two are 2, and three are 3, how many times can 1, 2, and 3 appear on average!

24. An interesting coin throwing Problem
Suppose there is a coin. The probability of throwing a word (on the back) and spending (on the front) is 0.5, and each coin throwing has nothing to do with the previous result. Now I am playing a game, throwing this coin continuously until two consecutive words appear. How many times can I end the game on average? Note: Once two "Words" are thrown consecutively, the game will end and you do not need to continue throwing them.
The first time I saw the above question was in a discussion of pongba's toplanguage. The author raised the question was Shuo Chen. At that time, I gave a solution and thought it was quite simple, let's take a look at the coin throwing process: first, you should throw a coin. If it is a flower, you must start with a new one. If it is a word, then you should throw another coin, if the new one is also a word, the game ends. If it is a flower, you need to start again. Based on this process, set the expected number of coins to t to obtain the relationship:
T = 1 + 0.5 T + 0.5 (1 + 0.5*0 + 0.5 T)
T = 6 can be obtained by solving the equation.
Or, according to the formula, N words need to be thrown consecutively. The result is quite concise: Tn = 2 ^ (n + 1)-2, TN indicates the expected number of consecutive n words that appear for the first time.
Reference http://www.cnblogs.com/atyuwen/archive/2010/09/12/coin.html

25. Problem description:
12 tall and low people are arranged in two rows, each of which must be arranged from low to high, and the second row is higher than the first row. How many sort methods are there?
This question is yd, because it hides a recursive link deep.

Problem Analysis:
We first arrange these 12 people from low to high, and then select 6 people in the first row, then the remaining 6 are definitely in the second row.
Use 0 to indicate that the corresponding person is in the first row, and use 1 to indicate that the corresponding person is in the second row. If there are 6 sequences of 0, 6, 6, and 1, the corresponding solution is used.
For example, 000000111111 corresponds
Row 1: 0 1 2 3 4 5
Row 2: 6 7 8 9 10 11
010101010101 corresponds
Row 1: 0 2 4 6 8 10
Row 2: 1 3 5 7 9 11
The problem is converted to the number of such 01 sequences that meet the condition.
When we observe the appearance of 1, we can consider whether this appearance can be placed in the second row. Obviously, the persons corresponding to 0, 1 that appeared before this 1
Either on the left side of this 1 or on the front of this 1. But there must be a zero number. Before this 1, count the numbers of 0 and 1 before this 1.
That is, the number of zeros must be greater than 1.
OK. The problem has been solved.
If 0 is regarded as an inbound stack operation, and 1 is regarded as an outbound stack operation, that is to say, the number of valid inbound and outbound stack sequences given six elements.
This is the catalan number, which is used only for the stack. It is also equivalent to the enumeration of Binary Trees. polygon is divided into the number of triangles. The number of methods in the Circular Arc insertion formula is C (2n, n)/(n + 1 ).

 

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.