Which of the following applications may use a stack?
a) A parentheses-balancing program.
b) Data Transfer between two asynchronous processes.
c) Tracking of local variables at run time.
d) Compiler Syntax Analyzer.
Which of the following applications may use a stack?
a) A parentheses-balancing program.
b) Data Transfer between two asynchronous processes.
c) Tracking of local variables at run time.
d) Compiler Syntax Analyzer.
Which of the following is not an advantage of trees?
a) Hierarchical structure b) Faster search c) Router algorithms d) Undo/Redo operations in a notepad
Algorithms like merge sort, quick sort, and binary search are based on
a) Greedy algorithm b) Divide and Conquer algorithm c) Hash table d) Parsing
Which of the following best approximates the ratio of the number of leaf nodes in a complete \(k\)-ary tree of depth \(n\)?
a) \(1-\frac1k\) b) \(1-\frac1n\) c) \(\frac1n\) d) \(\frac1k\)
What is the value of the postfix expression 6 3 2 4 + − *?
Given a binary search tree in Fig. 1, insert 27, 15, 63, 99, 70, and 85 (in this order) into the binary search tree. What is the post-order traversal?
What is the time complexity of the dynamic programming implementation of the longest common subsequence problem where the length of one string is “m” and the length of the other string is “n”?
For an ordered list of 11 items, how many comparisons will a linear search need before it knows that a value is NOT in the list?
Order the following functions by their growth rate from slowest to fastest: \(\sqrt n,\ n^{1.5},\ n^2,\ n\log n,\ n\log\log n,\ n\log^2n,\ 2^n,\ 2^{\log n}\).
What does the following function do for a given Linked List with the first node as head?
void fun1(struct node* head){
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
Consider the singly linked list shown in Table I whose head is item R. Assume the item S is added physically to the bottom of the list and inserted logically between R and Q. Show the link column entry after insertion.
| data | link | |
|---|---|---|
| 1 | L | 2 |
| 2 | P | 4 |
| 3 | R | 5 |
| 4 | B | Null |
| 5 | Q | 1 |
| 6 |
Table I.
You have a hash table with 8 slots and the following hash function: \(h(k)=(3k+7)\bmod 8\) with collisions resolved by using chaining.
(a) What is the probability that the first 3 slots are unfilled after the first 3 insertions? (5 分)
(b) If you want to search for the key 5, what index is it could be located in the hash table? (5 分)
(c) What is the time complexity? (5 分)
For the AOE (Activity on Edge) network described in Table II, answer the following questions:
[Note that state 1 is the starting state and state 10 is the goal state.]
(a) What is the earliest time the project can finish? (5 分)
(b) Please list all critical paths. (10 分)
| Activity | From | To | Time | Activity | From | To | Time |
|---|---|---|---|---|---|---|---|
| A1 | 1 | 2 | 5 | A8 | 4 | 5 | 3 |
| A2 | 1 | 3 | 5 | A9 | 5 | 7 | 1 |
| A3 | 2 | 4 | 3 | A10 | 5 | 8 | 4 |
| A4 | 3 | 4 | 6 | A11 | 6 | 10 | 4 |
| A5 | 3 | 5 | 3 | A12 | 7 | 9 | 5 |
| A6 | 4 | 6 | 4 | A13 | 8 | 9 | 2 |
| A7 | 4 | 7 | 4 | A14 | 9 | 10 | 2 |
Table II
Read the following array A in the given order, and show the corresponding trees:
A 15, 3, 8, 2, 10, 7, 6, 18, 5
(a) Construct a binary search tree for array A. Draw the resulting tree. (5 分)
(b) Show the pre-order sequence of the obtained tree in (a). (5 分)
(c) Construct a MAX-heap using the Top-Down Strategy. Draw the resulting heap. (5 分)
(d) Sort the numbers using heap sort in ascending order from the Max-Heap in (c). (5 分)
用 Google 帳號登入,才能閱讀詳解、保存購買紀錄與錯題。