Data structure written test question record

data structure

array

The correct reference to the array:
int a[10],*p=a;
*(p+2)
In C language, the string default '\0' occupies one byte, char, short, int occupy 1, 2, 3 respectively Byte
Java's char is unicode encoded, and can contain Chinese characters, except for some special Chinese characters. So char two bytes

1. Correct initialization of
A. int a[10]=(0,0,0,0)
B. int a[10]={}
C. int a[]={}
D. int a[10]={10*a}

a: parentheses changed to braces
b: yes, each element is 0
c: array length is 1, element is 0
d: array definition cannot be recursive

2. The container for easy insertion and deletion is
A.list
B.vector
C.map
D.set

a: The bottom layer of list is a doubly linked list
b: The bottom layer structure of vector is an array, which supports fast access
c: The bottom layer data structure of map is a red-black tree, Except for the hashmap disorder, other structures are ordered and not repeated
d: The underlying structure of set is a red-black tree. Except for hashset, other structures are ordered and not repeated

3. The following code can output good

	char a[]="ggood";
	char b[]="goodd";
	char *c;

Ac=a+1;
Bc=b;c[5]='/0';
C.*c="good";
D. Compilation error

A, if B is c[4] can also

4. If the array S[1...n] is used as the storage space of two stacks S1 and S2, for any stack, only when [1...n] is full can the stack operation not be performed, then the last of the two stacks The optimal allocation scheme is
A. The bottom position of S1 is 0, and the occupied position of S2 is n+1.
B. The bottom position of S1 is 0, and the bottom position of S2 is n/2.
C. The bottom position of S1 is 1. The bottom position of S2 is n
D. The bottom position of S1 is 1, and the bottom position of S2 is 1

Two test tubes interlocked C

5. Declare a pointer to an array with 10 elements, each element is a function pointer, the return value of this function is int, the parameter is int, the correct one is *
A.(int *p[10])(int*)
B.int [10]*p(int*)
C.int(*(*p)[10])(int*)
D.int((int*)[10])*p

Any array pointer, `int(*p)[10]`, and each element is a function pointer, function pointer `int(*pf)(int*)`, and then `(*p)[10]` Replacing pf as a whole gives `int(*(*p)[10])(int*)`

6. In an array with 8 int data, the data of the array is randomly given to find the largest and the second largest element must be compared several times
For the selection problem, the lower bound of finding the largest problem is n-1
to find the second The lower bound for large problems is n+logn-2

7. The correct answer is
A. The storage of the sequential storage structure must be continuous, and the storage structure of the chain storage is not necessarily continuous.
B. Sequential storage is only for linear structures, and chained storage is only for nonlinear structures.
C. The sequential storage structure can store ordered lists, but the linked storage structure cannot store ordered lists.
D. Chained storage structure saves storage space than sequential storage structure.

The chained storage structure can be used for both linear and nonlinear structures, so BC is wrong. Each node in the chained storage structure consists of two parts, the data field and the pointer field, which increases the storage space, so D is wrong.

8. Array definition int a[4][5], reference *(a+1)+2means the address of the element in the first row and second column of
the Aa[1][0] +2 Ba array Ca[0][1] +2 the value of the element in the first row and second column of the Da array


a is a row pointer, a+1 points to the next row, `*(a+1)` becomes a column pointer, and +2 is still a column pointer, pointing to the element of the first row and second column, select B

9. Let the array A[i, j], the length of each element of the array is 3 bytes, i is from 1 to 8, j is from 1 to 10, the array is stored from the first address BA of the memory, when the column is used as the main storage , the first storage address of element A[5][8] is
A.BA+180
B.BA+225
C.BA+222
D.BA+141

A
10. Let the array A=array[1…100,1…100] be stored in row-major order, each element occupies 2 storage units, the base address is 10, and LOC[5][5] should be
A.1020
B .1010
C.818
D.808

C

the stack

1. The wrong statement about the stack is
A. When the stack is empty, the stack must not be popped, otherwise it will overflow. B.
The stack must be a linear structure stored in sequence
. C. An empty stack is a stack with all elements being 0.
D. A stack input is ABCD, and the output can be obtained: CABD

Logical structure: linear (string, chained storage stack, sequential storage stack), tree, graph Storage structure: sequential storage (array - random access), chained storage (linked list - sequential access), index storage ( clue tree), hash storage (stack) `` ~~BCD~~ ``

2. About the stack and heap, the mistake is
A. The application method is different. The heap is automatically allocated by the system, and the stack is applied by yourself.
B. The size of the stack is fixed, and the size of the heap is limited by the effective virtual memory of the system.
C. The stack The system decides when to release the space, and the heap needs to decide when to release it
. D. The use of the heap is prone to fragmentation, but it is the most convenient to use

Heap: Cook and eat by yourself, you know when to put away the dishes, but waste (debris) may be generated. Stack: Canteen, the staff prepares meals and assigns the location for meals, and the staff helps to collect the dishes after eating, no waste, take the debris away Feed the pig `` ~~A~~ ``

##Machine Learning
1. Linear regression is correct
A. The basic assumption includes a random interference item of 0 and a standard normal distribution with a variance of 1
B. The basic assumption includes a random interference item of 0 and a normal distribution with the same variance
C. In When the basic assumption is violated, the ordinary least squares estimator is no longer the best linear unbiased estimator
D. When the basic assumption is violated, the model can no longer be estimated
E. DW can be used to test whether there is serial correlation in the residual
F. Multicollinearity will reduce the variance of the parameter estimates of

The random error term is a random variable with an expectation of 0 for all observations of the explanatory variable. The random error term consists of the same variance. The random error term is uncorrelated with each other. The random error term obeys a normal distribution. Allocate the location, the staff will help to collect the dishes after eating, there is no waste, and the pieces will be fed to the pigs `` ~~BCE~~ ``

Guess you like

Origin blog.csdn.net/cbx0916/article/details/130516002