Analysis of real questions for CSP-J preliminary rounds over the years | Multiple choice questions for CSP-J preliminary rounds in 2021 (1-15)

Learn C++ from a baby! Record the questions in the process of CSP-J preparation and study, and record every moment.

Attached is a summary post: Analysis of the real questions of the CSP-J preliminary competition over the years | Summary


1. Which of the following is not an object-oriented programming language ( ).

A.C++

B.Python

C.Java

D.C

[Answer]: D

【Analysis】

C language is process-oriented, not object-oriented

2. Which of the following awards is most relevant to the computer field is ( ).

A. The Oscars

B. Turing Award

c. Nobel Prize

D. Pulitzer Prize

[Answer]: B

【Analysis】

Oscars are for film, Pulitzers are for photography

3. The current mainstream computer storage data is finally converted into ( ) data for storage.

A. Binary

B. Decimal

C. Octal

D. Hexadecimal

[Answer]: A

【Analysis】

Mainstream computers convert data into binary for storage, because binary is the easiest to implement, and 0 and 1 can be represented by using high and low levels. ENIAC is a decimal computer

4. Take comparison as the basic operation, find the largest number among N numbers, and the minimum number of comparisons required in the worst case is ( ).

A.N^2

B.N

C.N-1

D.N+1

[Answer]: C

【Analysis】

The worst case requires adjacent comparisons, such as 1 and 2, 1 and 3, 1 and 4..., 1 and n, that is, N-1 times

5. For the stacking sequence of a, b, c, d, e, the following ( ) is not a legal stacking sequence.

A.a,b,c,d,e

B.e,d,c,b,a

C.b,a,c,d,e

D.c,d,a,e,b

[Answer]: D

【Analysis】

A is legal, if it enters the stack, it will come out

B is legal, that is, all 5 elements are put into the stack and then come out one by one

C is legal and can be mocked out

D is illegal, and a cannot come out, because the top of the stack is b at this time

The number after the serial number of each number in the popping sequence is smaller than it, and it is arranged in descending order (you can check after converting a/b/c/d/e to 1/2/3/4/5)

6. For an undirected connected graph (m>n) with n vertices and m edges, it is necessary to delete ( ) edges to make it a tree.

A.n-1

B.m-n

C.m-n-1

D.m-n+1

[Answer]: D

【Analysis】

A tree with n nodes has n-1 edges, so you need to delete m-(n-1) edges, choose D

7. The decimal number corresponding to the binary number 101.11 is ( ).

A.6.5

B.5.5

C.5.75

D.5.25

[Answer]: C

【Analysis】

1*2^2+1*2^0+1*2^-1+1*2^-2 = 5.75

8. If a binary tree has only a root node, then the height of the binary tree is 1. Does a complete binary tree of height 5 have ( ) different shapes?

A.16

B.15

C.17

D.32

[Answer]: A

【Analysis】

The tree after removing the nodes in the lower right corner of the full binary tree is a complete binary tree, that is, if all nodes are numbered, the numbers of all nodes traversed layer by layer in the complete binary tree are continuous. When the height is 5, there can be 16 leaf nodes on the fifth layer, and 0-15 leaf nodes can be deleted, a total of 16 forms

9. The suffix expression of the expression a*(b+c)*d is ( ), where "*" and "+" are operators.

A.**a+bcd

B.abc+*d*

C.abc+d**

D.*a*+bcd

[Answer]: B

【Analysis】

Infix expressions are converted to postfix expressions, you can use

1. Add brackets: a*(b+c)*d --> ((a*(b+c))*d)

2. Move the operator to the right of each pair of expressions: ((a(bc)+)*d)*

3. Remove brackets: abc+*d*

10, 6 people, two people form a team, a total of three teams, regardless of team number. There are ( ) different team situations.

A.10

B.15

C.30

D.20

[Answer]: B

【Analysis】

The first team, choose 2 people from 6 people, C(6,2) = 6*5/2 = 15

The second team, choose 2 people from 4 people, C(4,2) = 4*3/2 = 6

The third team, choose 2 people from 2 people, C(2,2) = 2*1/2 = 1

If 15*6*1 = 90, it is a sequential picking method, so it is necessary to remove the different permutations A(3,3) of the 3 teams, so 90 / A(3,3) = 15

11. The Huffman coding method in data compression coding is essentially a ( ) strategy.

A. Enumeration

B. Greedy

C. Recursion

D. Dynamic programming

[Answer]: B

【Analysis】

Huffman coding is essentially an application of Huffman tree. Huffman tree construction is to construct a binary tree with the smallest weighted path length given N leaf nodes with weights. If we want to minimize the length of the weighted path, we should put the nodes with smaller weights on the lower layer, because these nodes have longer path lengths and smaller weights, so the calculated weighted path length is smaller. This is actually a greedy strategy.

12. There are ( ) kinds of different three-digit numbers composed of the five numbers 1, 1, 2, 2, and 3.

A.18

B.15

C.12

D.24

[Answer]: A

【Analysis】

Assuming that the three-digit number is abc, according to the following calculation, there are 18 different numbers in total

a=1
  b=1 c=2/3 2种;
  b=2 c=1/2/3 3种;
  b=3 c=1/2 2种;
a=2
  b=1 c=1/2/3 3种;
  b=2 c=1/3 2种;
  b=3 c=1/2 2种;
a=3
  b=1 c=1/2 2种;
  b=2 c=1/2 2种;

13. Consider the following recursive algorithm

solve(n)
    if n<=1 return 1
    else if n>=5 return n*solve(n-2)
    else return n*solve(n-1)

Then the return result obtained by calling solve(7) is ( ).

A.105

B.840

C.210

D.420

[Answer]: C

【Analysis】

List the recurrence matrix, the result is 210, choose C

i     0  1  2         3         4          5          6           7
f(i)  1  1  2*f(1)=2  3*f(2)=6  4*f(3)=24  5*f(3)=30  6*f(4)=144  7*f(5)=210

14. Taking a as the starting point, perform depth-first traversal on the undirected graph on the right, then the number of points b, c, d, and e that may be the last to be traversed is ( ).

A.1

B.2

C.3

D.4

[Answer]: B

【Analysis】

List the results of all depth-first traversals:

abdce

acdbe

acedb

So there are 2 points as the last traversed point, namely b and e

15. There are four people who want to take a boat from point A to cross the river to point B. The boat is at point A at first. The boat can seat up to two people at a time. It is known that the crossing time of each of these four people by boat alone is 1, 2, 4, and 8 respectively, and the time for two people to cross the river by boat is the larger of the time for two people to cross the river alone. Then the shortest ( ) time allows all four people to cross the river to point B (including the time to drive the boat from point B back to point A)

A.14

B.15

C.16

D.17

[Answer]: B

【Analysis】

Using the greedy strategy, the first one is to hope that the person who takes the longest time to cross the river will go back and forth less, and will not come back after passing. The second is that the time for those who want to bring the boat back is as short as possible. draw a simulation

1&2&4&8   A  ---------  B
     4&8   A  ---1&2---> B
     4&8   A  <---1----  B 2
       1   A  ---4&8---> B 2
       1   A  <---2----  B 4&8
           A  ---1&2---> B 4&8

The shortest time=2+1+8+2+2=15

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/132696396