算法竞赛基础训练题_选择题

算法竞赛基础训练题
选择题

For a sequentially stored linear list of length N, the time complexities for query and insertion are : 对于长度为N的顺序存储线性列表,查询和插入的时间复杂度为:
B.O(1), O(N)

If a linear list is represented by a linked list, the addresses of the elements in the memory : 如果一个线性链表由一个链表表示,则内存中元素的地址:
B.may or may not be consecutive

When is the linked list structure suitable for representing a linear list L? 什么时候链表结构适合表示线性链表L?
A.frequently insert into and delete from L

What is NOT a feature of a linked list?什么不是链表的特性
B.easy for random query

Since the speed of a printer cannot match the speed of a computer, a buffer is designed to temperarily store the data from a computer so that later the printer can retrieve data in order. Then the proper structure of the buffer shall be a: 由于打印机的速度无法与计算机的速度相匹配,因此设计了一个缓冲区来暂时存储计算机中的数据,以便以后打印机可以按顺序检索数据。 那么适当的缓冲区结构应为a:
B.queue

Represent a queue by a singly linked list. Given the current status of the linked list as 1->2->3 where x->y means y is linked after x. Now if 4 is enqueued and then a dequeue is done, the resulting status must be: 用单个链表表示队列。 假设链表的当前状态为1->2->3,其中x->y表示y在x之后被链接。现在如果4被加入队列,然后一个出队列完成,结果状态必须是:
B.2->3->4

A tree is the most suitable structure to represent: 树是最适合表示的结构:
D.elements with hierarchical branching relations

For a binary search tree, in which order of traversal that we can obtain a non-decreasing sequence? 对于二叉搜索树,用什么顺序的遍历才能得到一个非递减的序列?
C.inorder traversal

To search a key in a complete binary search tree with N nodes, the average number of comparisons is: 在N个节点的完全二叉搜索树中搜索一个键,平均比较次数为:
A.O(logN)

If a binary search tree of N nodes is also a complete binary tree, then among the following, which one is FALSE? 如果一个有N个节点的二叉搜索树也是一个完全二叉树,那么下面哪个是FALSE?
B.The largest key must be on the last level

Which of the following is TRUE for any node in an AVL tree? 下面哪个选项对于AVL树中的任何节点都是正确的?
B.The absolute value of the difference between the heights of left and right subtrees is no more than 1左右子树高度差的绝对值不大于1

// Among the following trees, which one satisfies the definition of a height balanced tree? 在下列树中,哪一棵满足高度平衡树的定义?
在这里插入图片描述

The structure of a heap must be a: 堆的结构必须是
D.complete binary tree 完全二叉树

To build a heap from N records, the best time complexity is: 从N条记录构建一个堆,最佳的时间复杂度是:
B.O(N)

What kind of tree has the property that the nodes along the path from the root to any node are in sorted order? 什么样的树具有这样的特性从根结点到任意结点的路径上的节点都是有序的?
C.heap

To represent a graph with N vertices by the adjacency matrix, the size of the matrix must be: 用邻接矩阵表示一个有N个顶点的图,矩阵的大小必须为:
D.N^2

If a directed graph is represented by the adjacency matrix, then the in-degree of the i-th vertex is: 如果有向图用邻接矩阵表示,则第i个顶点的入度为:
C.the total number of non-zero entries in the i-th column第i列中非零元素的总数

Among the following statements about graph representations, which one is TRUE? 下列关于图表示的陈述中,哪个是正确的?
A.With adjacency matrix, the space taken is only related to the number of vertices, not the number of edges在邻接矩阵中,所占用的空间只与顶点的数量有关,与边的数量无关

Among the following statements about adjacency matrix, which one is TRUE? 在下列关于邻接矩阵的陈述中,哪个是正确的?
B.The adjacency matrix of a directed graph may or may not be symmetric有向图的邻接矩阵可能是对称的,也可能不是

In a directed graph, the relation between the sums of in-degrees S in and out-degrees S out of all the vertices is: 在有向图中,入度和出度之间的关系是
A.Sin==Sout

If a graph has N vertices, then it must have at most ____ edges. 如果一个图有N个顶点,那么它最多有____条边。
B.N(N−1)/2

DFS is similar to the __ traversal of a binary tree.
A.preorder先序遍历

The routes of airline flights can be represented by a directed graph. Which one of the following algorithms is the most suitable for finding the most economical flight path between any pair of cities? 航空公司航班的航线可以用有向图表示。 以下哪一种算法最适合在任何一对城市之间找到最经济的航线?
A.Dijkstra

What kind of problems can Dijkstra algorithm solve?
B.shortest path

The minimum spanning tree of any connected weighted graph: 任意连通加权图的最小生成树:
C.may not be unique

What is a critical path in an AOE network?
D.the longest path from the first to the last event从第一个项目到最后一个项目的最长路径

The best “worst-case time complexity” for any algorithm that sorts by comparisons only is: 对于任何只通过比较进行排序的算法来说,最好的“最坏情况时间复杂度”是:
C.O(NlogN)

Which one of the following relations is correct about the extra space taken by heap sort, quick sort and merge sort? 关于堆排序、快速排序和归并排序所占用的额外空间,下面哪个关系是正确的?
C.heap sort < quick sort < merge sort

Among the following methods, which one is stable?
C.merge sort

Among the algorithms that sort by comparisons only, which method has its worst-case time complexity bounded above by O(NlogN)? 在只进行比较排序的算法中,哪种方法的最坏情况时间复杂度在O(NlogN)以上?
B.merge sort

To sort N distinct elements in descending order by bubble sort, under which condition of the elements that the method will make the most number of swaps? 将N个不同的元素按冒泡排序降序排序,在什么条件下,该方法将进行最多次数的交换?
A.pre-sorted in ascending ordera .按照升序预先排序

To sort N records iteratively by merge sort, the number of runs is: 对N条记录进行归并排序,执行次数为:
A.O(logN)

To sort N records by merge sort, the worst-case time complexity is: 对N条记录进行归并排序,最坏情况下的时间复杂度为:
C.O(NlogN)

To sort N records by merge sort, the space complexity is: 对N条记录进行归并排序,空间复杂度为:
B.O(N)

Among the following methods, which one’s time complexity is always O(NlogN), no matter what the initial condition is? 在以下几种方法中,哪一种方法的时间复杂度总是O(NlogN),无论初始条件是什么?
C.heap sort

// If the input is a set of 10^5 1-digit numbers, which one of the following methods can sort them in O(N) time? 如果输入的是一组10^5的1位数字,下列哪一种方法可以在O(N)时间内对它们排序?
D.radix sort

Which sorting method removes one element at a time from the input data, finds the location it belongs within the sorted list, and inserts it there? 哪个排序方法从输入数据中每次删除一个元素,找到它在已排序列表中的位置,并将其插入其中?
A.insertion sort

To sort N records by quick sort, the worst-case time complexity is: 对N条记录进行快速排序,最坏情况时间复杂度为:
C.O(N^2)

To sort N elements by simple selection sort, the numbers of comparisons and movements are: 对N个元素进行简单选择排序,比较和移动次数为:
A.O(N^2), O(N)

To sort N elements by heap sort, the worst-case time complaxity is: 对N个元素进行堆排序,最坏情况下时间复杂度为:
C.O(NlogN)

To sort N elements by heap sort, the extra space complexity is: 按堆排序对N个元素进行排序,额外的空间复杂度为:
A.O(1)

In a hash table, “synonyms”(同义词) means: 在一个哈希表,“同义词”(同义词)的意思是:
B.two elements sharing the same hash value两个元素共享相同的哈希值

Among the following searching methods, which one’s average search time has nothing to do with the number of records? 在以下几种搜索方法中,哪一种平均搜索时间与记录数量无关?
C.hashing

The average search time of searching a hash table with N elements is: 搜索包含N个元素的哈希表的平均搜索时间为:
A.cannot be determined

What is a collision in hashing? 什么是哈希中的冲突?
C.Two elements with different keys share the same hash value两个具有不同键的元素共享相同的哈希值

To hash 10 elements into a hash table of 100000 cells, will there still be collisions? 将10个元素散列到一个有100000个单元格的散列表中,还会有碰撞吗?
B.May or may not be.

Which one of the following statements is TRUE about the consequential addresses generated by linear probing to resolve collisions? 关于由线性探测产生的解决冲突的相应地址,下列哪个陈述是正确的?
C.They can be greater than or smaller than, but never equal to the original has address它们可以大于或小于,但绝不等于原地址

If quadratic probing is used to resolve collisions, then which one of the following statements is TRUE about inserting a new element? 如果二次探测被用来解决冲突,那么关于插入一个新元素,下面哪个陈述是正确的?
B.The insertion may not be successful.

If a stack is used instead of a queue for the topological sort algorithm, does a different ordering result? 如果在拓扑排序算法中使用堆栈而不是队列,排序结果会不同吗?
C.Yes, sometimes.

What is the major difference among lists, stacks, and queues? 列表、堆栈和队列之间的主要区别是什么?
B.Stacks and queues are lists with insertion/deletion constraints

For the digraph given by the figure, the in-degrees and out-degrees of the vertices are: 对于图中给出的有向图,顶点的入度和出度为:
在这里插入图片描述
A.IN: 0, 2, 3, 1, 2; OUT: 3, 2, 1, 1, 1

BFS is similar to the __ traversal of a binary tree. BFS类似于二叉树的__遍历。
D.level-order 后序遍历

If the input is a set of 10^5 1-digit numbers, which one of the following methods can sort them in O(N) time? 如果输入的是一组10^5的1位数字,下列哪一种方法可以在O(N)时间内对它们排序?
C.bucket sort

// If the input is a set of 10^41-digit numbers, which one of the following methods can sort them in O(N) time? 如果输入的是一组10^41的数字,下列哪一种方法可以在O(N)时间内对它们进行排序?
A.bucket sort

// If the input is a set of 10^61-digit numbers, which one of the following methods can sort them in O(N) time? 如果输入的是一组10^61位数字,下列哪一种方法可以在O(N)时间内对它们排序?
B.bucket sort

If a binary search tree of N nodes is complete, which one of the following statements is FALSE? 如果一个有N个节点的二叉搜索树是完整的,下面哪个语句是假的?
C.the maximum key must be at a leaf node

If a graph with n vertices and e edges is represented by adjacency lists, then the time complexity of the topological sort must be: 如果一个有n个顶点和e条边的图用邻接表表示,则拓扑排序的时间复杂度必须为:
B.O(n+e)

To sort data files of size 10TB, the proper method is: 对于大小为10TB的数据文件,合适的排序方法是:
C.merge sort

Given the adjac ency matrix of a directed graph as the following: 给定有向图的邻接矩阵如下:

The out-degree and the in-degree of the vertex 2 (the index starts from 0) are __, respectively.
C.0 and 2

The two structures suitable for representing a sparse matrix are: 适用于表示稀疏矩阵的两种结构是:
A.triplets and multilists

Rehashing is required when an insertion to a hash table fails. Which of the following is NOT necessary to rehashing? 当插入哈希表失败时,需要重新哈希。 下面哪个选项对于重新哈希是不必要的?
A.change the collision resolution strategy .改变冲突解决策略

A relation R is defined on a set S. If for any elements a and b in S, we have that if “a R b” is true, then “b R a” must be true, then R is said to be __ over S. 关系式R是在集合S上定义的。如果对于S中的任意元素A和b,我们知道如果A rb为真,那么b rb一定为真,那么R就被称为__ / S。
C.symmetric

A relation R is defined on a set S. If for any elements a, b and c in S, we have that if “a R b” is true and “b R c” is true, then “a R c” must be true, then R is said to be __ over S. 关系R定义在集合S上。如果对于S中的任何元素A, b和c,我们知道如果“A rb”为真,“b rc”为真,那么“A rc”一定为真,那么R就被称为__ / S。
D.transitive

A relation R is defined on a set S. If for every element e in S, “e R e” is always true, then R is said to be __ over S. 关系R是在集合S上定义的。如果对于S中的每个元素e,“e R e”总是为真,那么R就被称为__ / S。
D.reflexive

To sort { 8, 3, 9, 11, 2, 1, 4, 7, 5, 10, 6 } by Shell Sort, if we obtain ( 4, 2, 1, 8, 3, 5, 10, 6, 9, 11, 7 ) after the first run, and ( 1, 2, 3, 5, 4, 6, 7, 8, 9, 11, 10 ) after the second run, then the increments of these two runs must be __ , respectively. 排序{8、3、9、11、2、1、4、7、5、10、6}的壳,如果我们获得(4 2 1 8 3,5,10,6,9日,11日,7)第一次运行后,和(1、2、3、5、4、6,7,8,9,11日,10)在第二次运行,那么这两个运行的增量必须__,分别。
B.3 and 2

Which one of the following problems can be best solved by dynamic programming? 下面哪个问题可以用动态规划最好地解决?
D.Longest common subsequence problem最长公共子序列问题

To delete X from a splay tree, the operations are: (1) Find X; (2)Remove X; (3) FindMin(T
R ); and the last operation is:
B.Make TL the left child of the root of TR使TL成为TR的根的左子结点

// Let T be a tree created by union-by-size with N nodes, then the height of T can be . 设T是一棵按大小联合创建的树,有N个节点,则T的高度可以为。
A.at most log2 (N) + 1 最多log2(N)+1

Let T be a tree of N nodes created by union-by-size without path compression, then the minimum depth of T may be设T是一棵由N个节点组成的没有路径压缩的按大小联合创建的树,则T的最小深度可以为
A.1

Which of the following statements about HASH is true?
A.the expected number of probes for insertions is greater than that for successful searches in linear probing method在线性探测方法中,插入的期望探针数大于成功搜索的期望探针数
B.if the table size is prime and the table is at least half empty, a new element can always be inserted with quadratic probing如果表的大小是素数,并且表至少有一半是空的,一个新的元素总是可以用二次探测插入
C.insertions are generally quicker than deletions in separate chaining method在单独的链接方法中,插入通常比删除快
D.all of the above

To find the minimum spanning tree with Prim’s algorithm for the following graph, a sequence of vertexes 6, 1, 2, 3 was found during the algorithm’s early steps. Which one vertex will be added in the next step? 为了用Prim算法找到下面图的最小生成树,在算法的早期步骤中找到了顶点6,1,2,3的序列。 哪一个顶点将被添加到下一步?

A.0

When selecting a sorting algorithm, which of the following factors must be taken into consideration besides the time and space complexities? 在选择排序算法时,除了考虑时间和空间的复杂性外,还必须考虑以下哪些因素?
I、the size of input data输入数据的大小
II、the structure used to store the data用于存储数据的结构
III、the stability of the algorithm算法的稳定性
IV、the initial condition of the data数据的初始条件
D.I, II, III and IV

How many of the following sorting methods use(s) Divide and Conquer algorithm?
Heap Sort堆排序
Insertion Sort插入排序
Merge Sort归并排序
Quick Sort快速排序
Selection Sort选择排序
Shell Sort希尔排序
A.2

Prim’s algorithm is a __
B.Greedy algorithm

// Given input { 321, 156, 57, 46, 28, 7, 331, 33, 34, 63 }. Which one of the following is the result after the 2nd run of the Least Signification Digit (LSD) radix sort? 给定输入{321,156,57,46,28,7,331,33,34,63}。 下面哪一个是第二次运行的最小意义数字(LSD)基数排序的结果?
D.→7→321→28→331→33→34→46→156→57→63

Given an integer sequence 25、84、21、47、15、27、68、35、20, after the Heapsort’s initial heap building, this interger sequence is .给定一个整数序列25,84,21,47,15,27,68,35,20,在heap sort的初始堆构建之后,这个整数序列是
C.15 20 21 25 84 27 68 35 47

Given an integer sequence 25、84、21、47、15、27、68、35、20, after the first run of the shell sorting by an increment 3, the integer sequence is .给定整数序列25、84、21、47、15、27、68、35、20,在第一次执行shell排序(按增量3)后,该整数序列为
D.25 15 20 47 35 21 68 84 27

To find the minimum spanning tree with Kruskal’s algorithm for the following graph. Which edge will be added in the final step? 用Kruskal算法求下图的最小生成树。 哪条边将在最后一步添加?
在这里插入图片描述
A.(v1,v2)

To find the minimum spanning tree with Prim’s algorithm from v1 for the following graph. Which edge will be added in the final step?
在这里插入图片描述
C.(v5,v6)

The minimum spanning tree of any weighted graph ____任意加权图____的最小生成树
D.may not exist

The minimum spanning tree of any connected weighted graph ____任意连通加权图____的最小生成树
B.must have a unique minimum weight

For the following function (where n>0)
the most accurate time complexity bound is:
A.O(logn)

int func ( int n )
{   int i = 1, sum = 0;
    while ( sum < n )  { sum += i; i *= 2; }
    return i;
}

// For the following function (where n>0)
the most accurate time complexity bound is:
D.O(logn)

int func ( int n )
{   int i = 1, sum = 0;
    while ( n > sum )  { i *= 2; sum += i; }
    return i;
}

For a non-empty doubly linked circular list, with h and t pointing to its head and tail nodes, respectively, the FALSE statement is: 对于非空双链循环链表,h和t分别指向其头节点和尾节点,FALSE语句为:
D.h->next == t

For a non-empty doubly linked circular list, with h and t pointing to its head and tail nodes, respectively, the TRUE statement is: 对于非空双链循环链表,h和t分别指向其头节点和尾节点,TRUE语句为:
A.t->next == h

Let’s traverse a complete binary tree in level-order, and define the level-order index of the root to be 1. Then for the i-th node visited, if its right child exists, then the index of this right child is___.让我们以level-order遍历一棵完整的二叉树,并定义根的level-order索引为1。 然后,对于访问的第i个节点,如果它的右子节点存在,则该右子节点的索引为___。
C.2i+1

Let’s traverse a complete binary tree in level-order, and define the level-order index of the root to be 1. Then for the i-th node visited, if its left child exists, then the index of this left child is___.让我们以level-order遍历一棵完整的二叉树,并定义根的level-order索引为1。 对于访问的第i个节点,如果它的左子节点存在,那么左子节点的索引是___。
A.2i

Suppose A is an array of length N with some random numbers. What is the time complexity of the following program in the worst case? 假设A是一个长度为N的数组,里面有一些随机数。 下面这个程序在最坏情况下的时间复杂度是多少?

void function( int A[], int N ) {
    int i, j = 0, cnt = 0;
    for (i = 0; i < N; ++i) {
        for (; j < N && A[j] <= A[i]; ++j);
        cnt += j - i;
    }
}

C.O(N)

The following list is a series of operations for a stack:

push 1
push 2
pop
push 3
pop
push 4
push 5
pop
pop
pop
push 6
push 7
pop
pop
push 8
pop
push 9
pop
Which is the correct pop-up sequence?
C.2 3 5 4 1 7 6 8 9

The following list is a series of operations for a stack:

push 1
push 2
push 3
pop
pop
push 4
push 5
pop
push 6
push 7
pop
pop
pop
push 8
pop
push 9
pop
pop
Which is the correct pop-up sequence?
C.3 2 5 7 6 4 8 9 1

In hashig with open addressing method,rehashing is definitely necessary when .在使用开放寻址方法的哈希中,当
A.an insertion fails

One of the following algorithms: Selection sort, Shell sort, Insertion sort, is applied to sort the sequence (2, 12, 16, 88, 1, 5, 10)in ascending order. If the resulting sequences of the first two runs are (2, 12 , 16, 10, 1, 5, 88) and (2, 12, 5, 10, 1, 16, 88), then after the third run, the number in front of 5 must be ____ . 选择排序、Shell排序、插入排序,对序列(2,12,16,88,1,5,10)进行升序排序。 如果前两次运行的结果序列是(2,12,16,10,1,5,88)和(2,12,5,10,1,16,88),那么在第三次运行后,5前面的数字必须是____。
B.1

One of the following algorithms: Selection sort, Shell sort, Insertion sort, is applied to sort the sequence (2, 12, 16, 88, 1, 5, 10)in ascending order. If the resulting sequences of the first two runs are (2, 12 , 16, 10, 1, 5, 88) and (2, 12, 5, 10, 1, 16, 88), then the algorithm must be .选择排序、Shell排序、插入排序,对序列(2,12,16,88,1,5,10)进行升序排序。 如果前两次运行的结果序列为(2、12、16、10、1、5、88)和(2、12、5、10、1、16、88),则算法必须为
A.Selection sort

// We can tell that there must be a lot of redundant calculations during the exhaustive search for the matrix multiplication problem, because the search work load is the Catalan number, yet there are only ___ different sub-problems M ij
我们可以看出,在穷举搜索矩阵乘法问题的过程中一定有大量的冗余计算,因为搜索工作量是加泰罗尼亚数,而只有___个不同的子问题M ij
B.O(N^2)

Why doesn’t Floyd algorithm work if there are negative-cost cycles? 如果存在负成本循环,为什么Floyd算法不起作用?
B.Because Floyd algorithm will terminate after finite steps, yet the shortest distance is negative infinity if there is a negative-cost cycle. 因为Floyd算法在有限步后终止,但如果存在负代价循环,则最短距离为负无穷。

.

  • 5
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

微__凉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值