华南理工大学06年数据结构B卷
06年B卷
Multiple Choice Questions
- Pick the growth rate that corresponds to the most efficient
algorithm as n gets large:
- 8nlog n
- 5n²
- n!
- 2ⁿ
- 8nlog n
- An algorithm must be or do all of the following
EXCEPT:
- Composed of concrete steps
- Correct
- Infinite
- No Ambiguous
- Composed of concrete steps
- Which statement is not true among the following:
- The number of 3-node binary trees in different shape is 5.
- The number of leaves in a non-empty full binary tree is one more
than the number of internal nodes.
- A cluster is the smallest unit of allocation for a file, so all
files are a multiple of the cluster size.
- The best case for my algorithm is n=1 because that is the fastest.
- The number of 3-node binary trees in different shape is 5.
- In the hash function, collision refers to:
- Two elements have the same sequence number.
- Different keys are mapped to the same address of hash table.
- Two records have the same key.
- Data elements are too much.
- Two elements have the same sequence number.
- The most effective way to reduce the time required by a
disk-based program is to:
- Improve the basic operations.
- Minimize the number of disk accesses.
- Eliminate the recursive calls.
- Reduce main memory use.
- Improve the basic operations.
- Which of the following cases is fit for a list L to be
implemented by link structure?
- It needs to modify the element values frequently.
- It needs to insert or delete elements in the list frequently.
- There are lots of elements in the list.
- It needs to modify the element values frequently.
- When a pointer requires 3 bytes and a data element requires
6 bytes, the linked list implementation requires less space than the
array-based list implementation when the array would be:
- less than 1/3 full.
- less than 2/3 full.
- less than half full.
- less than 3/4 full.
- less than 1/3 full.
- Which of the following is a true statement:
- In a BST, the left child of any node is less than the right child,
and in a heap, the left child of any node is less than the right
child.
- In a BST, the left child of any node could be less or greater than
the right child, but in a heap, the left child of any node must be less
than the right child.
- In a BST, the left child of any node is less than the right child,
but in a heap, the left child of any node could be less than or greater
than the right child.
- In both a BST and a heap, the left child of any node could be either less than or greater than the right child.
- In a BST, the left child of any node is less than the right child,
and in a heap, the left child of any node is less than the right
child.
- The time cost of Quicksort in the worst case is:
- O(n)
- O(log₂ n)
- O(n log₂ n)
- O(n²)
- O(n)
- In the following sequences of key value, which is a
heap?
- 16, 72, 31, 23, 94, 53
- 94, 23, 31, 72, 16, 53
- 16, 53, 23, 94, 31, 72
- 16, 23, 53, 31, 94, 72
- 16, 72, 31, 23, 94, 53
- In the following sorting algorithms, which is the best one
to find the first 10 biggest elements in the 1000 unsorted
elements?
- Insert sort.
- Heap sort.
- Quicksort.
- Shell sort.
- Insert sort.
- The function of replacement selection sort is:
- Select the maximal element.
- Generate the initial merge file.
- Merge the sorted file.
- Replace some record.
- Select the maximal element.
- Tree indexing methods are meant to overcome what deficiency
in hashing?
- Inability to handle range queries.
- Inability to handle updates.
- Inability to handle large data sets.
- None of all above.
- Inability to handle range queries.
- Assume that we have eight records, with key values A to H,
and that they are initially placed in alphabetical order. Now, consider
the result of applying the following access pattern: F D F G E G F A D F
G E. If the list is organized by the move-to-front heuristic, then the
final list will be:
- F G D E A B C H
- E G F D A B C H
- A B F D G E C H
- F D G E A B C H
- F G D E A B C H
- In the multiway merge for external sorting, for example,
0.5MB working memory, 4KB/block, yield 128 blocks for working memory.
Average run size is 1MB, so how many bytes can be sorted in one pass on
average:
- 256MB
- 128MB
- 4MB
- 64MB
- 256MB
答案:ACDBB BBCDD BBABB
问题:从一般树转化为二叉树
将一个 一般树 (任意节点可以有多个子节点)转换为 二叉树 (每个节点最多有两个子节点)。这种转换在数据结构中非常常见,特别是为了简化操作或提高算法效率时。
解决方法:左孩子-右兄弟表示法(Left-Child Right-Sibling Representation)
步骤:
保留第一个子节点作为左孩子
对于一般树中的每个节点,只保留它的第一个子节点,并将该子节点作为二叉树中的左孩子。将兄弟节点连接为右兄弟
对于一般树中的每个节点的其余子节点,将这些子节点以链表的形式依次连接,作为二叉树中的右兄弟。递归转换子树
对一般树中的每个节点的子树递归执行上述两个步骤。
构造树
A certain binary tree has the preorder enumeration as ABEDCFGHIJ and the inorder enumeration as EDBCAFIHGJ. Try to draw the binary tree and give the postorder enumeration. (The process of your solution is required!!!) (8 scores)
图论
(a) 图的表示
邻接矩阵表示(Adjacency Matrix)
矩阵定义如下,其中每个元素表示对应顶点之间的边的权重,若无边则为
∞
(或未填值):
1 | 2 | 3 | 4 | 5 | 6 | |
---|---|---|---|---|---|---|
1 | - | 10 | ∞ | 20 | ∞ | 2 |
2 | 10 | - | 3 | 5 | ∞ | ∞ |
3 | ∞ | 3 | - | ∞ | 15 | ∞ |
4 | 20 | 5 | ∞ | - | 11 | 10 |
5 | ∞ | ∞ | 15 | 11 | - | 3 |
6 | 2 | ∞ | ∞ | 10 | 3 | - |
邻接表表示(Adjacency List)
1 | 1 -> 2(10) -> 4(20) -> 6(2) |
(b) Dijkstra算法:从顶点1到所有其他顶点的最短路径
步骤:
- 初始化:设置起点1的距离为0,其余顶点距离为∞。
- 使用优先队列(或类似结构)选取当前最近的未访问顶点,更新邻接顶点的距离。
- 重复以上步骤,直到所有顶点都被访问。
结果路径:
- 1到2:10,路径为 (1 → 2)
- 1到3:13,路径为 (1 → 2 → 3)
- 1到4:12,路径为 (1 → 6 → 4)
- 1到5:5,路径为 (1 → 6 → 5)
- 1到6:2,路径为 (1 → 6)
(c) Kruskal算法:最小生成树(MST)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Totoroの旅!
评论