Order the following functions by their growth rate from slowest to fastest: \(O(n),O(n^2),O(n\log n),O(\log n),O(n!),O\!\left(n^{\frac{1}{\log}}\right)\). (6 分)
題目(共 8 題)
Convert the following conversion to postfix:
(a) Infix: \(a/b\times(c+d-e)-(f-g)\) (6 分)
(b) Prefix: \(\times\,/\,a-\times\,c\,b+d\,e-f\,g\) (6 分)
Sort the following data in ascending order by using three methods:
700, 123, 487, 1101, 657, 53, 188, 25.
Show your steps.
(a) Bubble Sort (5 分) (b) Quick Sort (5 分) (c) Radix Sort (5 分)
[Note: Please choose the first key as pivot in quick sort.]
Assume Data[1..100,1..100] is a two-dimensional integer array whose start address is \(00A0_{(16)}\). Please explain the possible addresses of Data[3,5]. (integer: 4 bytes) (10 分)
Demonstrate the insertion of the keys into a hash table:
12, 5, 88, 128, 17, 10, 33, 45, 27, 14, 64, 129.
[Note: Each bucket contains only 1 slot.]
(a) Let the table have 13 buckets, and let the hash function be \(h(k)=k\bmod 13\) and collision resolved by linear probing. (6 分)
(b) Describe the difference between collision and overflow. (6 分)
Given the following 10 numbers:
5, 3, 8, 2, 6, 7, 1, 9, 10, 4
(a) Construct a binary search tree for these numbers. Draw the resulting tree. (5 分)
(b) Show the postorder sequence of the obtained tree in (a). (5 分)
(c) Delete 8 from the obtained tree in (a) and show all possible resulting trees. (5 分)
(d) Construct a MIN-heap for these numbers using Top-Down Strategy. Draw the resulting heap. (5 分)
(e) Please Delete 1 from the obtained heap in (d) and show the resulting heap. (5 分)
About graph:
| A(G) | \(v_1\) | \(v_2\) | \(v_3\) | \(v_4\) | \(v_5\) | \(v_6\) | \(v_7\) |
|---|---|---|---|---|---|---|---|
| \(v_1\) | 0 | 5 | 0 | 0 | 0 | 0 | 9 |
| \(v_2\) | 5 | 1 | 3 | 7 | 0 | 0 | 0 |
| \(v_3\) | 0 | 3 | 1 | 0 | 0 | 0 | 0 |
| \(v_4\) | 0 | 7 | 0 | 0 | 1 | 0 | 2 |
| \(v_5\) | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| \(v_6\) | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| \(v_7\) | 9 | 0 | 0 | 2 | 0 | 0 | 0 |
(a) A(G) is the adjacency matrix of G. Give the adjacency multi-lists graph representation of the graph. (5 分)
(b) Find minimum spanning tree of the graph via Kruskal’s algorithm (start from \(v_4\)). (5 分)
Consider the tree below, show the output for each of functions:
(a) Given the following: (5 分)
void t1(TreeNode x)
{ if (x!=null)
{ printf("%c", x->key);
t1(x->right);
t1(x->left);
printf("%c", x->key);
}
}
(b) Given the following: (5 分)
void t2(TreeNode x)
{ if (x!=null)
{ t1(x->left);
t1(x->right);
printf("%c", x->key);
t1(x->left);
}
}