2019/6/19 Several multiple-choice questions of the Niukewang exam

1 There are 5000 record keywords to be sorted. If you need the fastest method to select the smallest 10 record keywords, you can use the following () method to achieve this goal.
(A) Quick sort (B) Heap sort (C) Merge sort (D) Insert sort

Solution: Choose B and sort by the smallest heap. As long as you filter 10 times on the basis of the initial heap, the time complexity of each filter is O(log2n). For other sorts, you must sort 5000 elements before you can select the smallest.

2 The opposite of pre-order sequence and post-order sequence is ().

  • A二叉排序树
  • B3个结点的二叉树
  • C平衡二叉树
  • D无右孩子的二叉树

Solution D The first order is: the root left and right, the post order is: left and right, the root middle order: the left root is left, so just choose the number of nodes equal to the height of the tree

3 The following is not the cause of process scheduling?

  • A进程执行完毕
  • B进程I/O请求排队
  • C进程死循环
  • D进程调用阻塞原语进入睡眠等状态

Solution: Choose C, because I don’t know whether the process is in an infinite loop, so it can’t cause process scheduling

Reasons for the height of the process https://blog.csdn.net/maxiaozhuang/article/details/39478339

4 Average search length of hash function chain address method 

Suppose the length of the hash table is 8, the hash function H(k)=k mod 7, the initial record key sequence is (32, 24, 15, 27, 20, 13), the calculation uses the chain address method as the conflict resolution method The average search length is ()

  • A1.4
  • B1.5
  • C1.6
  • D2 

First divide all the numbers by 7 {4,3,1,6,6,6}, because the chain address method is used: so there is 1 position of 1 in the linked list, and it can be found by searching it once. There is 1 position of 3 in the linked list, and it can be found after 1 search. There is 1 position of 4 in the linked list, and it can be found after 1 search. There are 3 positions of 6 in the linked list, the first 1 time, 2 times for the second, 3 times for the third

So (1*4+2*1+3*1)/6=1.5

ConcurrentHashMap read without lock, write with partial lock

ReadWriteLock read more and write less

Link: https://www.nowcoder.com/questionTerminal/2d5a65326a4c43ffa87ca7bf5ad1a632?toCommentId=33731
Source: Niuke
 

Which description of the following TCP connection establishment process is correct:

  • After receiving the SYN packet from the client, the A server will enter the SYN_SENT state after waiting for 2*ml
  • The B server will enter the SYN_RCVD state after receiving the ACK packet from the client
  • C When the client is in the ESTABLISHED state, the server may still be in the SYN_RCVD state
  • The D server does not receive the client confirmation packet, and will directly close the connection after waiting for 2*ml

Solution: choose C

A: The server will enter the SYN_RCVD state after receiving the SYN packet from the client

B: The server will enter the ESTABLISHED state after receiving the ACK packet from the client

D: In the second handshake, if the server finishes sending the SYN_ACK packet, if it has not received the client confirmation packet, the server will retransmit for the first time. Wait for a period of time if it has not been received for another retransmission. If the number of retransmissions exceeds the number allowed by the system, the system deletes the connection information from the semi-connection queue. Note that the time of each retransmission is different, so The specific time is uncertain 

Guess you like

Origin blog.csdn.net/weixin_40728070/article/details/92989118