- The reverse number of a sequence is defined as the total number of reversed pairs in the sequence, and the total number of element comparisons performed by the insertion sort in the list of size n is:
一个序列的逆序数定义为该序列中的逆序对总数,规模为n的列表中插入排序进行的元素比较总次数为:
1答案:B
- For ordered subsequences (set their length to k) during insertion sorting.
对于插入排序过程中的已排序子序列(设其长度为k):
2答案:C
- If in the recursive version of pre-order traversal, the access to the root node is followed by accessing the right subtree first and then the left subtree, then the call stack order of the left and right subtrees is:
若在递归版先序遍历中规定访问完根节点后先访问右子树再访问左子树,则左、右子树的调用栈顺序是:
3答案:A
- 在一棵树中,顶点p是顶点v的父亲,则它们的高度的关系是
4答案:A
- Read the function below (where 1≤x, y≤16) and indicate its function:
阅读下面函数(其中1≤x, y≤16),指出其功能:
5答案:A
解析:This function is a recursive version of the conversion of number systems
该函数是进制转换的递归版。
- which of the following are equal
① Numbers of different n-bit binary
② The number of legal parentheses matched by n pairs of parenthesesn
③ Numbers of different stack shuffle for {1, 2 … n}
④ Number of operator stack push operations during infix expression evaluation with n operators
以下几个量中相等的是:
①不同的n位二进制数个数
②对小括号所能构成的合法括号匹配个数
③{1, 2 … n}的不同栈混洗个数
④含n个运算符的中缀表达式求值过程中运算符栈push操作的次数
6答案:②③
解析:The push and pop in the stack shuffle correspond to the "(" and ")" in the parentheses match, so they are equal in number. (1 is 2^n, 2 is Catalan(n), 3 is Catalan(n), 4 ≤n)
栈混洗中的push和pop分别对应于括号匹配中的”( ”和”) ”,故它们数量相等.(①为2^n,②为 Catalan(n),③ 为Catalan(n),④≤n)