2014 Alibaba intern test questions

Source: Internet
Author: User
Tags array definition

1. single answer (10*2 '+ 10*3', 1 point for incorrect selection)

1. Assume that the ip address of a host is 192.168.5.121 and the subnet mask is 255.255.255.255.248. Then, the network number (including the subnet number) of the host is --

A.192.168.5.12 B 192.168.5.121C 192.168.5.120D 192.168.5.32

Reference C

Description: ip address and mask


In a 2.64-bit system, the defined variable int * a [2] [3] occupies the byte.

A 4 B 12 C 24 D 48

Reference D

Note: The Array Memory is all pointer, 64 is the system, and a pointer occupies 64 bits, that is, 8 bytes, 8*2*3 = 48.

If you ask the 64-bit machine how many bytes of int a [2] [3], the answer should be 24, because whether it is 32-bit or 64-bit, int Is Always 4 bytes.


3. in Linux, df-h/home and du-sh/home have different disk capacities, probably because --

A. The command is different, so the result must be different. B. The two command parameters are incorrect.

C. files opened by running processes are deleted, which is caused by the features of D and Linux.

Reference C

Note: I am not clear about Linux. Others have discussed C.


4. a c language program runs on a 32-bit machine. The program defines three variables xyz, where x and z are int, and y is short. When x = 127, y =-9, run the value assignment statement z = x + y and the values of xyz are --

A, x = 0000007FH, y = FFF9H, z = 00000076 H

B, x = 0000007FH, y = FFF9H, z = FFFF0076H

C, x = 0000007FH, y = FFF7H, z = FFFF0076H

D, x = 0000007FH, y = FFF7H, z = 00000076 H

Reference D


5. The following array definition is available: int [] [] myArray = new int [3] [] = {new int [3] {5, 6, 2 },

New int [5] {6, 9, 7, 8, 3 },

New int [2] {3, 2 }};

Then, the value of myArray [2] [2] is --

A, 9 B, 2 C, 6 D, cross-border

Reference D


6. The expected running time complexity of quick sorting is --

A, O (n ^ 2) B, O (nlogn) C, O (n) D, O (2 ^ n)

Reference B


7. Delete the I-th element in an ordered table with a length of n. Move the I-th element. If an element is inserted before I, move it back.

A, n-I, n-I + 1 B, n-I + 1, n-I, C, n-I, n-I, d, n-I + 1, n-I + 1

Reference answer


8. The output of the C ++ program below is --

Void f (char * x)
{
X ++;
* X = 'a ';
}


Int main ()
{
Char str [sizeof ("hello")];
Strcpy (str, "hello ");
F (str );
Cout <str;
Return 0;
}

A, hello B, halloC, allevels, and none of the above

Reference B


9. The execution result of the following programs is ___

Char fun (char x, char y)

{

If (x) return y;

}

Int main ()

{

Int a = '0', B = '1', c = '2 ';

Printf ("% c \ n", fun (a, B), fun (B, c )));

}

A. function call error B, 2C, 0D, 1

Reference B

Note: a = '0' is not 0


10. When n = 6, the return value of the following function is --

Int foo (int n)

{

If (n <= 2)

Return n;

Return foo (n-1) + foo (n-2 );

}

A, 1 B, 8 C, 13, D, 21

Reference C

Note: Fibonacci


11. On a mainstream PC, the time required to call f (35) is roughly --

Int f (int x)

{

Int s = 0;

While (x --> 0) s + = f (x );

Return max (s, 1 );

}

A, several milliseconds B, several seconds C, several minutes D, several hours

Reference D

Note: The calculation result is 2 ^ 35, and the program runs multiple recursion times. The specific execution process is unclear at the moment...


12. in a tree T with a degree of 4, if there are 20 nodes with a degree of 4, 10 nodes with a degree of 3, and 1 node with a degree of 2, the number of leaf nodes in the tree T is --

A, 41 B, 82 C, 113 D and 122

Reference B

Note: The total degree is the total number of edges. The total degree is + 1 = the sum points. There are n leaf nodes, then there are 20*4 + 10*3 + 1*2 + 10*1 + 1 = 20 + 10 + 1 + 10 + n

N = 82


13. If there is a stack S and ABCD is added to the stack in order, the order of the output stack cannot exist --

A. dcba B, BACDC, BADCD, and CABD

Reference D

Note: There is no explanation for this question.


14. Use binary search to find the time complexity of an element x in the ordered array a [n --

A, O (n) B, O (n ^ 2) C, O (logn) D, O (nlogn)

Reference C


15. The maximum traffic on each road is shown. Could you tell me that the maximum traffic from S to T is --

A, 46 B, 47 C, 54 D, 77


Reference answer

Note: The largest stream algorithm is used. I have simulated it and I cannot find the 46 largest stream algorithm.


16. One day, a young man came to Zhang's shop and spent 80 yuan to buy a souvenir with the original price of 160 yuan. This gift costs 65 yuan. During the checkout, the young man took out 100 yuan. boss Zhang had no change at the time, and he used the 100 yuan to change the change to the store next door and asked the young man 20. but the store next door later found that the 100 was fake money, and boss Zhang had to pay 100 yuan. How much money does boss Zhang lose in this transaction --

A, 65 B, 85 C, 100 D, 185

Reference B

Note: from the perspective of a young man, I gave a fake money with a value of 0. I got 65 yuan of clothes and 20 yuan of retrieved clothes. I made a profit of 85 yuan in total; from the perspective of the store next door, although I got a fake money, but later I made up the money and couldn't get in; from the perspective of boss Zhang, I gave my clothes, I found another change and lost 85.


17.2 ^ 100 mod 7 = _

A, 2 B, 3 C, 4 D, 5

Reference answer

Note: original formula = (2 ^ 10mod 7) ^ 10 mod 7


18. A company operates in the East and South China regions. When its performance is summarized at the end of the year, it finds that the monthly customer conversion rate of the two regions is (= number of customers who become members/number of customers who access the store) increase by 10% and 5% respectively. Which of the following statements is true --

A. Although the monthly conversion rate of sub-accounts has increased, the overall monthly conversion rate of the company may be reduced.

B. The market recognizes the business more and more customers who access the store become members.

C. Customers in East China are more likely to be converted. The company should focus its business on this region.

D. Customers in South China need to increase the conversion rate. The company should focus its business on this region.

Note: I won't do this either. I am blind to B... Wait for other more accurate answers...


19. A tennis competition where eight or more people participate depends on the player's strength. Numbers 1-8 and 1 are respectively the strongest, and the gap between strength and strength is less than or equal to 2. 8 people held the 1/4 finals, and the winning 4 people continued to the semi-finals until they won the championship. Q: The biggest contestant who may win the championship is --

A, 4 B, 6 C, 7 D, 8

Reference B

Note: If you want to give 7 a chance, you cannot find it.


20. A country is very patriarchal. If a family has a girl, they need another one until they have a boy. Assuming that the probability of being male and female is equal, ask the average number of girls in each household

A, 0.5 B, 2/3C, 1D, 4/3

Reference C

Note: Two ideas can be used to calculate expectations directly based on the probability formula, but this may be troublesome. The second idea is that there is no human intervention here, and the probability of giving birth to boys and girls is equal. This means that every family has a boy, and every family can have a girl on average.


2. Non-targeted choice questions (correct: 5 points; 2 points missing; 0 points not selected; +-2 points incorrect)

21. Which of the following statements about C language is false --

A. Memory leakage generally means that the program has applied for A piece of memory. After using the memory, it is not released in time, resulting in A large amount of memory occupied by the program.

B. You cannot apply for a memory block exceeding the physical memory size of the machine through calling the malloc (size_t) function.

C. You cannot use the memory release function free (void *) to directly return the used physical memory to the operating system.

D. You can directly apply for physical memory through the memory allocation function malloc (size_t ).

My answer BCD

Note: I am not sure about this question... If you have better answers and explanations, please advise.


22. The following statements about the Binary Search Tree include --

A. When the left and right subtree of the Left subtree are to be deleted, the maximum node of the Left subtree can only be used to replace the node to be deleted.

B. Given the results of the forward and backward orders of a binary search tree, this binary tree cannot be determined.

C. Given a binary search tree, the time complexity required to sort by node value is linear.

D. Given a binary search tree, it can be converted into a balanced binary search tree in linear time complexity.

My answer CD

Note: you are not sure about this... Please advise


23. Zhou Wei, known as a Chinese Rain Man, can open 16 digits to the power of 14 in just one minute. Which of the following digital clocks cannot become a candidate answer --

A, 11.0 B, 12.0C, 13.0D, 14.0E, 15.0

Reference ADE

Note: I have no good solutions... AE is Meng, D can test the following... However, based on the computer, the answer was ADE.


24. There are three packages, each with two balls. The ball in pack A is white, the ball in pack B is black, and the ball in pack C is black and white. A random package is taken and a random ball is taken from it. The ball is white. The probability that the remaining balls in this bag are white is --

A, 0 B, 0.33 C, 0.5 D, 0.66 E, 1

Reference D

Note: Pack B is excluded first. The white balls in A are numbered 1 white and 2 white. Now we can simulate the ball fetch process in three cases: A pack 1 white 2 white, A pack 2 white 1 white, C pack first white then black. The probability of the remaining balls being white is 2/3.


Iii. Fill in and answer questions


25. The resolution of an electronic eye is 640*360 ). The maximum bandwidth of Bluetooth 4.0 is 24 Mbps. Can I use this technology to transmit 50 real-color (24-bit) frames per second to its screen. If yes, explain the cause. If no, explain how long it takes to transmit a frame theoretically.

Reference Answer: No. transfer a frame in about 0.23 seconds.


26. Merge N ordered linked lists whose lengths are M. The merged linked lists are also in order, and the time complexity is --

I wrote O (m * n * logn), and my roommate wrote O (m * n ). My roommate cannot convince me, and I cannot convince him... Dizzy...


27. The four members of the ABCD bridge at night, which took 1, 2, 5, and 10 minutes respectively. They only had one flashlight and they had a maximum of two people together. Please arrange a scheme to allow all four persons to use the minimum time and provide a scheme.

Reference answer: 17

Note: 1, 2 first pass, 2 left 1 back, 5, 10 again, 2 back, 1, 2 again.


28. The following code implements binary search of an ordered integer array. Please point out the bug.

Int binary_search (int * array, int length, int key)
{
Int start = 0, end = length-1;
While (end> start)
{
Int middle = (start + end)/2;
Int tmp = array [middle];
If (tmp <key)
Start = middle;
Else if (tmp> key)
End = middle;
Else
Return middle;
}
Return-1;
}

Note: This type of problem bug is easy to find and cannot be described...


29. Skip the linked list ~

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.